DETAILS------------>
[HistoricDetailVariableInstanceUpdateEntity[variableName=myJsonVariable, variableInstanceId=8eef66d3-3f44-11e8-9e0f-0242ac130002, revision=0, serializerName=null, longValue=null, doubleValue=null, textValue=null, textValue2=null, byteArrayId=null, activityInstanceId=Task_19mc7r5:8ee1f951-3f44-11e8-9e0f-0242ac130002, eventType=null, executionId=8edffd7f-3f44-11e8-9e0f-0242ac130002, id=8eef66d5-3f44-11e8-9e0f-0242ac130002, processDefinitionId=8edffd7f-3f44-11e8-9e0f-0242ac130002, processInstanceId=8edffd7f-3f44-11e8-9e0f-0242ac130002, taskId=null, timestamp=Fri Apr 13 14:00:32 EDT 2018], HistoricDetailVariableInstanceUpdateEntity[variableName=myJsonVariable, variableInstanceId=8eef66d3-3f44-11e8-9e0f-0242ac130002, revision=1, serializerName=null, longValue=null, doubleValue=null, textValue=null, textValue2=null, byteArrayId=null, activityInstanceId=Task_10dfa25:8ef1d7d9-3f44-11e8-9e0f-0242ac130002, eventType=null, executionId=8edffd7f-3f44-11e8-9e0f-0242ac130002, id=8efa153c-3f44-11e8-9e0f-0242ac130002, processDefinitionId=8edffd7f-3f44-11e8-9e0f-0242ac130002, processInstanceId=8edffd7f-3f44-11e8-9e0f-0242ac130002, taskId=null, timestamp=Fri Apr 13 14:00:32 EDT 2018]]
JSON Values In order of occurance------------>
{"cat":123,"dog":321}
{"horse":111}
First Value------------>
{"cat":123,"dog":321}
javascript:
var system = java.lang.System
var processInstanceId = execution.getProcessInstanceId()
var historyService = execution.getProcessEngineServices().getHistoryService()
var variable_instance_id = execution.getVariableInstance("myJsonVariable").getId()
var variable_history_updates = historyService.createHistoricDetailQuery()
.processInstanceId(processInstanceId)
.variableUpdates()
.variableInstanceId(variable_instance_id)
.orderByVariableRevision()
.asc()
.list()
system.out.println("DETAILS------------>");
system.out.println(variable_history_updates.toString());
system.out.println("JSON Values In order of occurance------------>");
for each (var item in variable_history_updates) {
system.out.println(item.getValue().toString())
}
system.out.println("First Value------------>");
system.out.println(variable_history_updates.get(0).getValue().toString())
Also make sure you that your history query is not occurring in the same transactions as when you set your variable(s). You can add “async after” on the last task before you are doing this query to ensure that the variable updates have been committed to the db