how to test value of workflow variable A (mgrApproval) in below script & set new value to workflow variable B (requestStatus) based on value of A.

Confluence User - 05 Jan, 2017

import org.joget.workflow.model.service.*;

WorkflowManager wm = (WorkflowManager) pluginManager.getBean("workflowManager");

//store the value of workflow variable mgrApproval in String variable test1

String test1 = wm.getProcessVariable(workflowAssignment.getProcessId(), "mgrApproval");

//check if mgrApproval is set to rejected & set requestStatus to Rejected.

if (test1 == "Rejected"){

        wm.activityVariable(workflowAssignment.getActivityId(), "requestStatus", "Rejected");
}

//else set requestStatus to In Progress
else
{
       wm.activityVariable(workflowAssignment.getActivityId(), "requestStatus", "In Progress");
}

beanshell;forms;workflowmanager

7


06 Jan, 2017
confluenceUser
confluenceUser

Hi, perhaps you could temporarily output some debugging messages to the console or logs using System.out.println. You can also check the values of the process variables in Monitoring Apps

06 Jan, 2017
confluenceUser
confluenceUser

Hi. I have added the below line before the if statement: System.out.println(test1); However, i am not seeing any output in the joget logs. What i am doing wrong?

06 Jan, 2017
confluenceUser
confluenceUser

If the System.out is not writing anything on the console for 'test1', you could maybe try doing System.out.println("mgrApproval = "+#variable.mgrApproval#); // like what I mentioned in my comment above, If this prints the variable's value in the console (catalina.out), you can use this to compare the values instead. Let me know if this helps!

06 Jan, 2017
confluenceUser
confluenceUser

Another thing you could try to check is the comparison. Instead of using test1 == "Rejected" you could try using "Rejected".equals(test1). By right BeanShell should accept both, but you never know since BeanShell is a Java interpreter.

06 Jan, 2017
confluenceUser
confluenceUser

I don't seem to get the output in joget.log file. catalina.log contains like 3 lines only. The console window shows the same log as joget.log. Is there something i need to setup may be to be able to see the System.out.println() statement in the logs?

06 Jan, 2017
confluenceUser
confluenceUser

I have tried using "Rejected".equals(test1) as suggested, however requestStatus is always set to "In Progress". It seems the IF check always evaluates to False regardless of the value of mgrApproval. How can i output the values of test1 to the log or console to troubleshoot the If-Else block? Thanks.

10 Jan, 2017
confluenceUser
confluenceUser

If you are on Linux then System.out would output to the catalina.out log file. On Windows it should appear in your Tomcat console.

RELATED QUESTIONS

Your answer


To answer a question you'll need an account.

Print