how to use default REST API to set/create TASK VARIABLES

436 views
Skip to first unread message

lim chee hong

unread,
Dec 11, 2013, 12:56:25 AM12/11/13
to camunda-...@googlegroups.com
hi all,
i have question on how to set the TASK VARIABLE using REST API. I cant find any REST API at this moment. i tried to use /task/taskId/complete (complete task API) and set the variables. but the variables will store under PROCESS INSTANCE instead of USER TASK. Please advice. Thanks.

Roman Smirnov

unread,
Dec 11, 2013, 7:52:59 AM12/11/13
to camunda-...@googlegroups.com
Hi,

if you complete a task and set the variables, he tries to set each variable on the task, but if the variable is not already existing, it will be created in the most outer scope. This means the process instance in case the task is related to an execution.

Currently it is not possible to set local variables on a task via the REST API. At the moment you can use therefore the following Java API methods "TaskService#setVariableLocal()" or "TaskService#setVariablesLocal()". Then it will be only available for this task and will be destroyed, when the task is completed.

I hope that helps you?

Cheers,
Roman

lim chee hong

unread,
Dec 11, 2013, 11:34:55 AM12/11/13
to camunda-...@googlegroups.com
Hi Roman,
Thanks for your sharing. it really helps me a lot. the reason why i need to set variable into the task is because when a user task is completed, calling application passes extra variables. This variable will be used to determine routing to which subsequent user task. Eg : when Manager complete a "Approval" user task. Under this task, manager have options either reject, approve or ask for rework. these options will determine the workflow routes to which user tasks. if this is the case, i cannot set the variable under task because it will be destroyed and cannot used by others task anymore. how can i store the "option" that selected by manager? Please advice.

besides that, i also confuse between process instance VS execution. what is the diff between process instance VS execution? also what is the diff if i set variable under process instance VS execution? Please advice.

Roman Smirnov

unread,
Dec 13, 2013, 9:54:01 AM12/13/13
to camunda-...@googlegroups.com
Hi,

therefore you have to pass the variable "option" too, if the task will be completed. In case of the REST API use the following method:


The variable "option" will be saved in the process instance and can be determined to decide which Task should be executed then.

You can find in our user guide some documentation about a process instance and an execution.

Does it help you?

Cheers,
Roman
Reply all
Reply to author
Forward
0 new messages