03-20-2018 06:09 AM
Hi everyone,
I can't add variables to a task throw rest-api. May be i understand the document with mistakes
my activiti version:
activiti-6.0.0 from Download Now | Activiti.org
1. why do this?
I want to add a variables to a task, then i can query it by this variables value.
2. replay
I) create a task
II) find it with query/task
Here is info
all json:
```
{ "data": [ { "id": "7501", "url": "http://localhost:8080/dumii-activiti/service/runtime/tasks/7501", "owner": "shadow", "assignee": "shadow", "delegationState": null, "name": "测试任务", "description": "任务描述", "createTime": "2018-03-20T17:02:09.498+08:00", "dueDate": null, "priority": 50, "suspended": false, "taskDefinitionKey": null, "tenantId": "", "category": null, "formKey": null, "parentTaskId": null, "parentTaskUrl": null, "executionId": null, "executionUrl": null, "processInstanceId": null, "processInstanceUrl": null, "processDefinitionId": null, "processDefinitionUrl": null, "variables": [] } ], "total": 1, "start": 0, "sort": "id", "order": "asc", "size": 1 }
```
III) add variables to this task
find this variables with "Get all variables on a task"
I'm sure that variables created successful
IV)But this variables is not under task
Thanks,
dark-wind
03-22-2018 12:21 PM
Did you try includeProcessVariables & includeTaskLocalVariables parameters? Activiti User Guide
03-20-2018 09:43 AM
I suspect that when the REST API calls the engine API for that service/query/tasks request it does so using a query on tasks rather than tasks with variables. It probably does this because retrieving the variables too is a more complex query that returns more data and in some cases quite a lot of data (since you might have a lot of variables). But perhaps for your case you do want the variables too? I'm not sure if that's what you want or if you're looking for a custom endpoint that tells you tasks that have a task variable of a particular value. If so maybe another approach would be to query for the variable first and then use that result to find the task? I'm not entirely sure whether there is an endpoint that lets you do what you're looking for. Which version of Activiti or Alfresco Process Services are you using?
03-20-2018 10:38 PM
Thank you for your prompt reply,
My activiti version is activiti-6.0.0 and I used activiti-rest.Yeah,we can search a variable to get a task id. Then ,use this id to query task.But I care that both document and swagger-UI show me the option about “taskVariables”:Activiti User Guide . I believe that rest-api support it and i want to use this option
03-21-2018 02:26 AM
I think you are right. I am not immediately sure where to check though. Maybe some searches/digging in the v6 code base for those rest end points or some strings that appear in the swagger Activiti/ at 6.x · Activiti/Activiti · GitHub
03-22-2018 12:21 PM
Did you try includeProcessVariables & includeTaskLocalVariables parameters? Activiti User Guide
03-23-2018 12:37 AM
oh, you are right.
I didn't config this parameters for query/task .
It works with this request:
{ "includeTaskLocalVariables":true }
thanks for your help again.This is very helpful
Explore our Alfresco products with the links below. Use labels to filter content by product module.