Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

Workflow variables

Avatar

Former Community Member
How to retrieve values of workflow process variables and modify those values using ES API?
5 Replies

Avatar

Former Community Member
Nearly every solution component in ES either reads from or writes to process variables. You can retrieve and modify these variables according to the design of each of these components; or if you want to read and modify variables according your own terms then the best component to use is "SetValue". It can be found in the "Foundation" service grouping.



Cheers,



Lachlan



http://www.avoka.com

Avatar

Former Community Member
Thanks.I have already use "SetValue" for assign PDF form data and modify those values.



But I need to do this activity through JAVA API code?Please Give suggestion.

Avatar

Former Community Member
2 options are that you could add some script to an execute script step or write and deploy your own solution component.

Avatar

Level 10
From a pure Java API point of view, you can use query manager to get the list of variables for a particular process. This is an example:



public List getProcessVariables(String processName){

List _result = null;

try{

_result = _queryManager.getProcessVariables(processName);

}

catch(Exception e){

System.out.println("Error in TaskManager getProcessVariables");

System.out.println(e.getMessage());

}

return _result;



You can also get the variables value for a particular process instance with the following code:



public List getProcessVariablesValue(long processID){

List procVar = null;



try {



procVar = _queryManager.getProcessVariableValues(processID);



if(procVar == null) {

System.out.println("No process variables");

}



int size = procVar.size();

System.out.println(size);

for(int i = 0; i < size; i++){

MultiTypeVariable var = ((MultiTypeVariable)procVar.get(i));

System.out.println("name = " + var.getName());

System.out.println("value = " + var.getValue());

System.out.println("getTitle = " + var.getTitle());

System.out.println("getType = " + var.getType());

System.out.println("isSearchable = " + var.isSearchable());

System.out.println("isVisible = " + var.isVisible());

}

}

catch (Exception e) {

e.printStackTrace();

System.out.println("ERROR!!!");

}

return procVar;

}



... where _queryManager = TaskManagerClientFactory.getQueryManager(_factory);



Hope this helps.



Jasmin