class Camunda::Task
Finds tasks by business key and task definition and allows you to report a task complete and update process variables. If a business key isn't supplied when creating a process definition, you can still retrieve UserTasks by using the `.find_by` helper provided by Her. @see Camunda::ProcessDefinition
@see github.com/remi/her @example
Camunda::Task.find_by(taskDefinitionKey: 'UserTask')
@example
# You can get all tasks with the `.all.each` helper tasks = Camunda::Task.all.each # And then complete all tasks like so tasks.each(&:complete!)
Public Class Methods
find_by_business_key_and_task_definition_key!(instance_business_key, task_key)
click to toggle source
@example
user_task = Camunda::Task.find_by_business_key_and_task_definition_key!('WorkflowBusinessKey','UserTask')
@param instance_business_key [String] the process instance business key @param task_key [String] id/key of the user task @return [Camunda::Task]
# File lib/camunda/task.rb, line 22 def self.find_by_business_key_and_task_definition_key!(instance_business_key, task_key) find_by!(processInstanceBusinessKey: instance_business_key, taskDefinitionKey: task_key) end
Public Instance Methods
bpmn_error!(error_code, error_message, vars={})
click to toggle source
# File lib/camunda/task.rb, line 38 def bpmn_error!(error_code, error_message, vars={}) self.class .post_raw("#{self.class.collection_path}/#{id}/bpmnError", errorCode: error_code, errorMessage: error_message, variables: serialize_variables(vars))[:response] .tap do |response| raise SubmissionError, response.body[:data][:message] unless response.success? end end
bpmn_escalation!(escalation_code, vars={})
click to toggle source
# File lib/camunda/task.rb, line 47 def bpmn_escalation!(escalation_code, vars={}) self.class .post_raw("#{self.class.collection_path}/#{id}/bpmnEscalation", escalationCode: escalation_code, variables: serialize_variables(vars))[:response] .tap do |response| raise SubmissionError, response.body[:data][:message] unless response.success? end end
complete!(vars={})
click to toggle source
Complete a task and updates process variables. @example
user_task = Camunda::Task.find_by_business_key_and_task_definition_key!('WorkflowBusinessKey','UserTask') user_task.complete!
@param vars [Hash] variables to be submitted as part of task completion
# File lib/camunda/task.rb, line 31 def complete!(vars={}) self.class.post_raw("#{self.class.collection_path}/#{id}/complete", variables: serialize_variables(vars))[:response] .tap do |response| raise SubmissionError, response.body[:data][:message] unless response.success? end end