# API java: get old variable value

**URL:** <https://community.ofelia.com/t/api-java-get-old-variable-value/5857>\
**Category:** Q&A\
**Created:** [20 April 2015 13:08 UTC](https://community.ofelia.com/t/api-java-get-old-variable-value/5857 "2015-04-20T13:08:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![m.vizzini](https://avatars.discourse-cdn.com/v4/letter/m/848f3c/32.png) [@m.vizzini](https://community.ofelia.com/u/m.vizzini)\
**Post date:** [20 April 2015 13:08 UTC](https://community.ofelia.com/t/api-java-get-old-variable-value/5857/1 "2015-04-20T13:08:24Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![anthony.birembaut](https://avatars.discourse-cdn.com/v4/letter/a/ed8c4c/32.png) [@anthony.birembaut](https://community.ofelia.com/u/anthony.birembaut)\
**Post date:** [20 April 2015 15:05 UTC](https://community.ofelia.com/t/api-java-get-old-variable-value/5857/2 "2015-04-20T15:05:41Z")

</div>

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”);

Hope that helps  
Anthony

---

<div class="post-metadata">

**Author:** ![m.vizzini](https://avatars.discourse-cdn.com/v4/letter/m/848f3c/32.png) [@m.vizzini](https://community.ofelia.com/u/m.vizzini)\
**Post date:** [20 April 2015 15:51 UTC](https://community.ofelia.com/t/api-java-get-old-variable-value/5857/3 "2015-04-20T15:51:59Z")

</div>

Ok, thanks.

I try it.

Manolo
