API java: get old variable value
Hi, I have an active process with three tasks (task1, task2, task3) and one variable "name". Each task sets the value of the variable name: task1 => name = 'Pippo' task2 => name = 'Pluto' task3 => name = 'Mario'
Using processAPI.getProcessDataInstances or processAPI.getArchivedProcessDataInstances Bonita always returns the value of task3 Mario.
How should I do to get the value of the task1 'Pippo'?
Thanks Manolo
2 answers
Hi Manolo,
I don't think there such a method in the API. But you can use the method ProcessAPI#evaluateExpressionsOnCompletedActivityInstance with an expression of type Variable. Something like:
Map<Expression, Map<String, Serializable>> expressions = new HashMap<Expression, Map<String,Serializable>>();
ExpressionBuilder expressionBuilder = new ExpressionBuilder();
expressionBuilder.createDataExpression("name", String.class.getName());
expressions.put(expressionBuilder.done(), new HashMap<String, Serializable>());
Map<String, Serializable> evaluationResult = processAPI.evaluateExpressionsOnCompletedActivityInstance(archivedActivityInstanceId, expressions);
String nameDataValue = evaluationResult.get("name");
ExpressionBuilder expressionBuilder = new ExpressionBuilder();
expressionBuilder.createDataExpression("name", String.class.getName());
expressions.put(expressionBuilder.done(), new HashMap<String, Serializable>());
Map<String, Serializable> evaluationResult = processAPI.evaluateExpressionsOnCompletedActivityInstance(archivedActivityInstanceId, expressions);
String nameDataValue = evaluationResult.get("name");
Hope that helps Anthony