Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

    • element - Element that this binder is tie to. (org.joget.apps.form.model.Element)
    • rows - Data to be store. Contains one or more org.joget.apps.form.model.FormRow object. (org.joget.apps.form.model.FormRowSet)
    • formData - The data holder of the whole form. (org.joget.apps.form.model.FormData)

Expected Return Object:

    • Same A org.joget.apps.form.model.FormRowSet object which stored.

Samples:

Bulk create users based on the grid data.

...

Samples:

        Randomly assign an a user in a department to a workflow activity.

...

Code Block
languagejava
import org.joget.apps.form.model.FormRow;
import org.joget.apps.form.model.FormRowSet;
import org.joget.apps.app.service.AppUtil;
import org.joget.plugin.base.PluginManager;
import org.joget.apps.form.model.FormLoadBinder;
import org.joget.workflow.model.service.WorkflowManager;

    String formDefId = "ExpensesClaimEntry";  //change this to the form id used to load grid data
    String foreignKey = "claim"; //change this to the foreign key field id
      
    // Reuse Multi Row Binder to load data
    PluginManager pluginManager = (PluginManager) AppUtil.getApplicationContext().getBean("pluginManager");
    WorkflowManager workflowManager = (WorkflowManager) AppUtil.getApplicationContext().getBean("workflowManager");
    FormLoadBinder binder = (FormLoadBinder) pluginManager.getPlugin("org.joget.plugin.enterprise.MultirowFormBinder");
     
    //Load from the grid table
    binder.setProperty("formDefId", formDefId);
    binder.setProperty("foreignKey", foreignKey);
    
    FormRowSet rows;
    rows = binder.load(null, "#assignment.processId#", null);
    
	//loop through records returned
    for (FormRow row : rows) {
        try {
            Map variableMap = new HashMap();
            variableMap.put("status", row.getProperty("purpose"));
            
			//start a new process instance with data from each row
            //processStart(String processDefId, String processId, Map<String, String> variables, String startProcUsername, String parentProcessId, boolean startManually)
            workflowManager.processStart("expenseclaim:latest:process1", null, variableMap, null, row.getProperty("id"), false);
        } catch (Exception e) {}
    }

Use as Process Route Decision

Note:

    • By using a decision plugin, the specified route transition rules set explicitly in the process design will be ignored.

Injected Variables:

    • workflowAssignment - The workflow tool activity assignment object. (org.joget.workflow.model.WorkflowAssignment)
    • pluginManager - Plugin Manager service bean for convenient usage. (org.joget.plugin.base.PluginManager)
    • appDef - App definition of the process. (org.joget.apps.app.model.AppDefinition)
    • request - Http Request object of current HTTP Request. Not available if the tool is trigger by Deadline. (javax.servlet.http.HttpServletRequest)

Expected Return Object:

Samples:

Decide to approve or reject a request based on the value of the workflow variable "status".

Code Block
languagejava
import org.joget.workflow.model.DecisionResult;

//Transition Name to go to
String transitionApprove = "approve";
String transitionReject = "reject";

//Workflow variable ID to set
String workflowVariable = "status";

DecisionResult result = new DecisionResult();

/* Bean Shell Decision supports hash variable, and has access to the process instance context. */
//System.out.println("Value of \'status\' wf-var in this process instance is: " + "#variable.status#");

if ("yes".equalsIgnoreCase("#variable.status#")) {
    result.addTransition(transitionApprove);
    result.setVariable(workflowVariable, "ApprovedByBeanShellDecision");
} else {
    result.addTransition(transitionReject);
    result.setVariable(workflowVariable, "RejectedByBeanShellDecision");
}

/* For use cases requiring multiple node routing, do set boolean below as true. */
//result.setIsAndSplit(true);

return result;

Use as Userview Permission

Injected Variables:

    • user - User object of current logged in user (org.joget.directory.model.User)
    • requestParams - Request parameters map of current HTTP Request (java.util.Map)

Expected Return Object:

    • A boolean value to indicate the user is authorized.

Samples:

Check the user is in a group and is an admin user.

...