Joget DX 8 Stable Released
The stable release for Joget DX 8 is now available, with a focus on UX and Governance.
The Bean Shell plugin allows one to write custom Java code to achieve what other process tools may not.
Figure 1: Bean Shell Properties
Name | Description |
---|---|
Script | Script in Java. Please see Bean Shell Programming Guide for code example. |
Activity Tool Type Plugin is a plugin that will be executed when the workflow reaches a System Tool activity. System Tool activities must be placed in the workflow diagram and the Beanshell plugin configured in the Process's Activity Mapping for this to work. In this plugin, there are two context variables available for the script to use :
import java.util.HashMap; import java.util.Map; import org.joget.apps.app.model.AppDefinition; import org.joget.apps.app.service.AppService; import org.joget.apps.app.service.AppUtil; import org.joget.apps.form.model.FormRow; import org.joget.apps.form.model.FormRowSet; import org.joget.apps.form.service.FormUtil; import org.joget.workflow.model.WorkflowAssignment; import org.joget.workflow.util.WorkflowUtil; //Constant variable String formDefId = "approvalForm" ; //Service bean AppService appService = (AppService) AppUtil.getApplicationContext().getBean( "appService" ); //Get primary key String id = appService.getOriginProcessId(workflowAssignment.getProcessId()); //Get existing data FormRowSet rowSet = appService.loadFormData(appDef.getAppId(), appDef.getVersion().toString(), formDefId, id); FormRow row = null ; if (rowSet == null || rowSet.isEmpty()) { rowSet = new FormRowSet(); row = new FormRow(); row.setId(id); rowSet.add(row); } else { row = rowSet.get( 0 ); } //Set values row.setProperty( "field1" , "value 1" ); row.setProperty( "field2" , "value 2" ); row.setProperty( "field3" , "value 3" ); //Save appService.storeFormData(appDef.getAppId(), appDef.getVersion().toString(), formDefId, rowSet, id); |
import org.joget.workflow.model.service.WorkflowManager; WorkflowManager workflowManager = (WorkflowManager) pluginManager.getBean( "workflowManager" ); String approvalLvl = workflowManager.getProcessVariable(workflowAssignment.getProcessId(), "ApprovalLevel" ); String newApprovalLvl = String.valueOf(Integer.parseInt(approvalLvl)+ 1 ); workflowManager.activityVariable(workflowAssignment.getActivityId(), "ApprovalLevel" , newApprovalLvl); |
...