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 ,

  • No labels

3 Comments

  1. Hi there,

    To get the value of a workflow variable, you can simply use the following code with hash variable.

    String value = "#variable.userList#";

    You do not need to go through all the troubles with all the lines of coding like you had.

    Cheers.

    Hugo

  2. 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 .

    1. Your code looks right. Basically you only need this 3 lines of code to update a workflow variable value.

      import org.joget.workflow.model.service.*;
      
      WorkflowManager wm = (WorkflowManager) pluginManager.getBean("workflowManager");
      
      wm.activityVariable(workflowAssignment.getActivityId(), "variableId", "variableValue");

      Read up more at Bean Shell Programming.

      Cheers.