Joget DX 8 Stable Released
The stable release for Joget DX 8 is now available, with a focus on UX and Governance.
Hello Guys ,
I am trying to get a variable into beanshell programming by using :
WorkflowManager workflowManager = (WorkflowManager) pluginManager.getBean("workflowManager");
String users = workflowManager.getProcessVariable(workflowAssignment.getProcessId(), "userlist");
But i am having this error :
Sourced file: inline evaluation of: ``import org.joget.apps.form.model.; import org.joget.apps.form.lib.; import org . . . '' : Typed variable declaration : Attempt to resolve method: getBean() on undefined variable or class name: pluginManager : at Line: 33 : in file: inline evaluation of: ``import org.joget.apps.form.model.; import org.joget.apps.form.lib.; import org . . . '' : pluginManager .getBean ( "workflowManager" )
Do i need to change pluginManager.getBean("workflowManager"); into something else ?
Thank for your help. Best ,
3 Comments
Hugo
Hi there,
To get the value of a workflow variable, you can simply use the following code with hash variable.
You do not need to go through all the troubles with all the lines of coding like you had.
Cheers.
Hugo
KARUPPANNAN Meven
Thank Hugo !
If i want to change the content of the variable into new value and add it back to the assignment .
Eg : Get variable , change value and set it back to the assignment .
Here is the code i used :
WorkflowManager workflowManager = (WorkflowManager) pluginManager.getBean("workflowManager");
String users = workflowManager.getProcessVariable(workflowAssignment.getProcessId(), "userlist");
StringBuffer NewUserList = new StringBuffer();
NewUserList.append("values add inside a for condition").append("&");
String NewUserListFinalV = NewUserList.toString();
workflowManager.activityVariable(workflowAssignment.getActivityId(), "userlist", NewUserListFinalV);
My variable userlist will look like : user1&user2&user3&user4 .
How can it be done ? Thank Hugo .
Hugo
Your code looks right. Basically you only need this 3 lines of code to update a workflow variable value.
Read up more at Bean Shell Programming.
Cheers.