cancel
Showing results for 
Search instead for 
Did you mean: 

Process Variables, Activiti REST

anjan
Champ in-the-making
Champ in-the-making
I am using the latest version of Activiti (5.17.0).  I have deployed Activiti REST and Activiti Explorer (as separate web apps) in Tomcat.  Both the apps are configured to use the same MySQL database.  I created a Process definition and successfully deployed it through activiti-explorer.

Now using the Activiti REST API, I started a process instance.

<pre>
http://localhost:8080/activiti-rest/service/runtime/process-instances
POST
{
    "processDefinitionId": "Review:1:2508",
    "variables": [
        {
            "name": "assignTo",
            "value": "admin"
        },
        {
            "name": "taskPriority",
            "value": "taskPNormal"
        },
        {
            "name": "workflowDescription",
            "value": "desc"
        },
       {
           "name":"dueDate",
           "value":"2015-04-15T00:42:12Z",
           "type":"date"
       }
    ]
}
</pre>

and I got the below successful response:
<pre>
    {
       "id": "10001",
       "url": "http://localhost:8080/activiti-rest/service/runtime/process-instances/10001",
       "businessKey": null,
       "suspended": false,
       "ended": false,
       "processDefinitionId": "Review:1:2508",
       "processDefinitionUrl": "http://localhost:8080/activiti-rest/service/repository/process-definitions/Review:1:2508",
       "activityId": "reviewTask",
       "variables":
       [
       ],
       "tenantId": "",
       "completed": false
    }
</pre>
Here I don't see the process variables (variables is an empty array in the json response).

I also tried to get this information by adding the request paramer "includeProcessVariables" (tried with yes/true for the value), but the URL http://localhost:8080/activiti-rest/service/runtime/process-instances/10001?includeProcessVariables=...
doesn't return the process variables.

My objective is to show all the Process Variables injected at the start of the workflow at all the User Tasks in the workflow.  Am I missing something here?  Please advice.
4 REPLIES 4

yvoswillens
Champ in-the-making
Champ in-the-making
Hi,

you can use the boolean property "returnVariables" in your request to have the variables returned in the response.
This property wil be included in a future documentation revision.

Kind Regards,

Yvo

anjan
Champ in-the-making
Champ in-the-making
Hi Yvo, thanks for your reply.  You are correct.  By adding "returnVariables" in the first POST request, the process variables are returned in the success response.  But my problem is still not solved.  When I want to get this information at a later point of time in the workflow (i.e., in the User Task), the JSON response still doesn't contain this information.  Please advice the best way to get this information at any point in the workflow process.

anjan
Champ in-the-making
Champ in-the-making
Hi Yvo, I noticed that, the following REST API is available to get the variable information.  Is this what we need to use?  Please confirm.
<code>
runtime/process-instances/{processInstanceId}/variables
</code>

nekojiru
Champ in-the-making
Champ in-the-making
If add query parameter  includeProcessVariables=true may take variables.
see user guide
Table 65. List of process instances - URL query parameters
more detail.

Regards.