Can't filter tasks according to

Hi all,

I have a task as following.

{
“id”: “f1389054-9b56-11ea-a0da-005056b63d36”,
“name”: “Select Operator”,
“assignee”: null,
“created”: “2020-05-21T14:33:50.473+0300”,
“due”: null,
“followUp”: null,
“delegationState”: null,
“description”: null,
“executionId”: “f1389051-9b56-11ea-a0da-005056b63d36”,
“owner”: null,
“parentTaskId”: null,
“priority”: 50,
“processDefinitionId”: “restServiceCallDemo:1:3a2dec8e-9b48-11ea-a0da-005056b63d36”,
“processInstanceId”: “f1389051-9b56-11ea-a0da-005056b63d36”,
“taskDefinitionKey”: “selectOperator”,
“caseExecutionId”: null,
“caseInstanceId”: null,
“caseDefinitionId”: null,
“suspended”: false,
“formKey”: null,
“tenantId”: null
}

By calling /task/f1389054-9b56-11ea-a0da-005056b63d36/variables/sunny api, my task has variable as following:
{
“sunny”: {
“type”: “Integer”,
“value”: 1,
“valueInfo”: {}
}
}

If I call /task/f1389054-9b56-11ea-a0da-005056b63d36/variables then I can see my variable. But when I want to filter task list by this variable, I can’t get the task. It returns an empty list. I am calling /task (POST) with following request body:

{
“taskVariables”:
[{“name”: “summy”,
“value”: “1”,
“operator”: “eq”
}]
}

When I call /task (POST) with following request I can get the task.

{
“processInstanceId”: “f1389051-9b56-11ea-a0da-005056b63d36”
}

What is the main problem here? Why isn’t task list filtering by task variables working? I need your help because this is very crucial on my project. I should filter tasks according to task variables for my work pool.

Thanks

Hi @alimercetin

I guess that the variable you are looking for is a process instance variable. (not a task variable)

Try below request body

{
processVariables”:
[{“name”: “summy”,
“value”: “1”,
“operator”: “eq”
}]
}

Please have a look at below docs to get more details in regard to variable scopes

https://docs.camunda.org/manual/latest/user-guide/process-engine/variables/#variable-scopes-and-variable-visibility

Hi @hassang

I also thought that and tried this but it is still not working.

Hi,

Let me explain one thing. If I start instance with variables, I can filter tasts by these process variables. There is no problem with this. But if I call https://docs.camunda.org/manual/7.5/reference/rest/task/variables/put-task-variable/
then I can’t filter tasks according to this new variables that I have added later by calling api. That’s the main problem that I have now.

Hi @alimercetin,
Could you please post your code for both calls (update and get list)

Hi,

I am calling camunda’s own api’s via postman. I should also mention that we are working with standalone version of camunda.

To start process : camunda-enpoint/engine-rest/process-definition/key/dkey/start (POST)

To add variable to task: camunda-enpoint/engine-rest/task/taskId/variables/sunny (PUT)
request Body:
{
“value” : “1”, “type”: “Integer”
}

To get task variable: camunda-endpoint/engine-rest/task/taskId/variables
response :
{
“sunny”: {
“type”: “Integer”,
“value”: “1”,
“valueInfo”: {}
}
}

To get task list : camunda-enpoint/engine-rest/task (POST)
request body:
{
“processVariables”:
[{“name”: “sunny”,
“value”: “1”,
“operator”: “eq”
}]
}

Then it returns nothing :slight_smile:

Hi @alimercetin,

Have you tried to remove double quotes surrounding the value as it is a numeric value

{“name”: “sunny”,
“value”: 1,
“operator”: “eq”
}

Hi,

Yes, you were right. It is a double quotes issue. It work when I remove them. Thanks for your help :slight_smile: