/query/historic-task-instances retrieve wrong task variable data

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-10-2016 03:37 PM
When I create a process definition, I used user task listener to set task variables to setup and track status and next status history required by client. I queried act_hi_varinst (select * from act_hi_varinst where proc_inst_id_='1627936' order by ID_) and found that info is correctly inserted as show below:
ID INST_ID EXEC_ID TASK_ID NAME TYPE TEXT
1627947 1627936 1627936 1627946 status string Assigned
1627948 1627936 1627936 1627946 nextStatus string Pending Review
1627952 1627936 1627936 1627951 status string Pending Review
1627953 1627936 1627936 1627951 nextStatus string Pending Close
1627958 1627936 1627936 1627957 status string Pending Close
1627959 1627936 1627936 1627957 nextStatus string Closed
However, when I query instance history with rest api /query/historic-task-instances, I got wrong history task variable info. As you can see, the task variables for different tasks are all the same as last task vraiables while they should be different as shown in act_hi_varinst table.
{
"data": [
{
"id": "1627946",
…
"variables": [
{
"name": "nextStatus",
"type": "string",
"value": "Closed",
"scope": "local"
},
{
"name": "status",
"type": "string",
"value": "Pending Close",
"scope": "local"
}
]
},
{
"id": "1627951",
…
"variables": [
{
"name": "nextStatus",
"type": "string",
"value": "Closed",
"scope": "local"
},
{
"name": "status",
"type": "string",
"value": "Pending Close",
"scope": "local"
}
]
},
{
"id": "1627957",
…
"variables": [
{
"name": "nextStatus",
"type": "string",
"value": "Closed",
"scope": "local"
},
{
"name": "status",
"type": "string",
"value": "Pending Close",
"scope": "local"
}
]
}
]
}
Is this a bug?
Thanks,
Aiming
ID INST_ID EXEC_ID TASK_ID NAME TYPE TEXT
1627947 1627936 1627936 1627946 status string Assigned
1627948 1627936 1627936 1627946 nextStatus string Pending Review
1627952 1627936 1627936 1627951 status string Pending Review
1627953 1627936 1627936 1627951 nextStatus string Pending Close
1627958 1627936 1627936 1627957 status string Pending Close
1627959 1627936 1627936 1627957 nextStatus string Closed
However, when I query instance history with rest api /query/historic-task-instances, I got wrong history task variable info. As you can see, the task variables for different tasks are all the same as last task vraiables while they should be different as shown in act_hi_varinst table.
{
"data": [
{
"id": "1627946",
…
"variables": [
{
"name": "nextStatus",
"type": "string",
"value": "Closed",
"scope": "local"
},
{
"name": "status",
"type": "string",
"value": "Pending Close",
"scope": "local"
}
]
},
{
"id": "1627951",
…
"variables": [
{
"name": "nextStatus",
"type": "string",
"value": "Closed",
"scope": "local"
},
{
"name": "status",
"type": "string",
"value": "Pending Close",
"scope": "local"
}
]
},
{
"id": "1627957",
…
"variables": [
{
"name": "nextStatus",
"type": "string",
"value": "Closed",
"scope": "local"
},
{
"name": "status",
"type": "string",
"value": "Pending Close",
"scope": "local"
}
]
}
]
}
Is this a bug?
Thanks,
Aiming
Labels:
- Labels:
-
Archive
4 REPLIES 4
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-20-2016 08:30 AM
Without knowing what your task listener does .. this is hard to say. Does it set local vars? if so, it could return different variables …

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-01-2016 03:33 PM
Yes, the task listener for task create is set to add local variables. Query act_hi_varinst table directly give correct results but activiti rest api /query/historic-task-instances give incorrect results. That is why I think it is a bug of the rest api. Here is the listener implementation in the definition.
<activiti:taskListener event="create" class="org.activiti.engine.impl.bpmn.listener.ScriptTaskListener">
<activiti:field name="script">
<activiti:string><![CDATA[status="Assigned";
nextStatus="Pending Review"; task.setVariableLocal("status", status); task.setVariableLocal("nextStatus", nextStatus);]]></activiti:string>
</activiti:field>
<activiti:field name="language">
<activiti:string><![CDATA[groovy]]></activiti:string>
</activiti:field>
</activiti:taskListener>
Aiming
<activiti:taskListener event="create" class="org.activiti.engine.impl.bpmn.listener.ScriptTaskListener">
<activiti:field name="script">
<activiti:string><![CDATA[status="Assigned";
nextStatus="Pending Review"; task.setVariableLocal("status", status); task.setVariableLocal("nextStatus", nextStatus);]]></activiti:string>
</activiti:field>
<activiti:field name="language">
<activiti:string><![CDATA[groovy]]></activiti:string>
</activiti:field>
</activiti:taskListener>
Aiming

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-25-2016 02:36 PM
The issue happens with version 5.19. I can no longer reproduce this issue after we upgraded to version 5.21 recently.
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-27-2016 08:17 AM
I vaguely seem to remember that we did work in the area of local variables a couple of months ago indeed.
Glad to hear it's fixed!
Glad to hear it's fixed!
