Versions Compared

Key

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

...

  • pluginManager
  • workflowAssignment
  • appDef  - AppDefinition

A Beanshell activity tool type plugin that sets a form data:

Code Block
import java.util.ArrayListHashMap;
import java.util.logging.Logger.Map;
import org.joget.apps.app.model.AppDefinition;
import org.joget.apps.pluginapp.baseservice.PluginManagerAppService;
import java.util.logging.FileHandlerorg.joget.apps.app.service.AppUtil;
import org.joget.apps.workflowform.model.service.WorkflowManagerFormRow;
import org.joget.apps.form.model.FormRowSet;
import org.joget.apps.form.service.FormManagerFormUtil;
import org.joget.formworkflow.model.Form;

FormManager formManager.WorkflowAssignment;
import org.joget.workflow.util.WorkflowUtil;

//Constant variable
String formDefId = "approvalForm";

//Service bean
AppService appService = (FormManagerAppService) pluginManager.getBean("formManagerappService");
processId

//Get primary key
String id = appService.getOriginProcessId(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

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

Increment a workflow variable value:

...