I can't add variables to a task throw rest-api

cancel
Showing results for 
Search instead for 
Did you mean: 
darkwind
Active Member

I can't add variables to a task throw rest-api

Jump to solution

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

i read Activiti User Guide  but still don't know why

Thanks,
dark-wind

1 Solution

Accepted Solutions
bassam_al-saror
Alfresco Employee

Re: I can't add variables to a task throw rest-api

Jump to solution

Did you try includeProcessVariables & includeTaskLocalVariables parametersActiviti User Guide 

View solution in original post

5 Replies
ryandawson
Alfresco Employee

Re: I can't add variables to a task throw rest-api

Jump to solution

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?

darkwind
Active Member

Re: I can't add variables to a task throw rest-api

Jump to solution

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

ryandawson
Alfresco Employee

Re: I can't add variables to a task throw rest-api

Jump to solution

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 

bassam_al-saror
Alfresco Employee

Re: I can't add variables to a task throw rest-api

Jump to solution

Did you try includeProcessVariables & includeTaskLocalVariables parametersActiviti User Guide 

darkwind
Active Member

Re: I can't add variables to a task throw rest-api

Jump to solution

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