Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: add increment variable beanshell

...

Code Block
import java.util.ArrayList;
import java.util.logging.Logger;
import org.joget.plugin.base.PluginManager;
import java.util.logging.FileHandler;
import org.joget.workflow.model.service.WorkflowManager;
import org.joget.form.model.service.FormManager;
import org.joget.form.model.Form;

FormManager formManager = (FormManager) pluginManager.getBean("formManager");
processId = workflowAssignment.getProcessId();
Form form = formManager.loadDynamicFormByProcessId("T01", processId); // in this example, form's table is T01

formData = form.getCustomProperties();
formData.put("c_columnname","new value"); // the form data field to be set is columnname
form.setCustomProperties(formData);
formManager.saveForm(form);

Increment a workflow variable value

Code Block

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);

This beanshell script retrieves workflow variable 'ApprovalLevel', convert it into integer, add 1, and stores it back as the same workflow variable.