Joget DX 8 Stable Released
The stable release for Joget DX 8 is now available, with a focus on UX and Governance.
...
Code Block | ||
---|---|---|
| ||
import java.util.Map; import javax.servlet.http.HttpServletRequest; import org.joget.apps.app.model.AppDefinition; import org.joget.apps.app.service.AppService; import org.joget.apps.app.service.AppUtil; import org.joget.workflow.model.service.WorkflowManager; import org.joget.workflow.model.WorkflowAssignment; import org.joget.workflow.model.WorkflowProcess; public Object execute(WorkflowAssignment assignment, AppDefinition appDef, HttpServletRequest request) { AppService appService = (AppService) AppUtil.getApplicationContext().getBean("appService"); WorkflowManager workflowManager = (WorkflowManager) AppUtil.getApplicationContext().getBean("workflowManager"); //get current record id String recordId = appService.getOriginProcessId(assignment.getProcessId()); //get process WorkflowProcess process = appService.getWorkflowProcessForApp(appDef.getAppId(), appDef.getVersion().toString(), "process2"); //start process workflowManager.processStart(process.getId(), null, null, null, recordId, false); return null; } //call execute method with injected variable return execute(workflowAssignment, appDef, request); |
Code Block | ||
---|---|---|
| ||
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.workflow.model.WorkflowAssignment; String formDefId = "hr_expense_new"; String fieldId = "status"; String fieldValue = "Submitted"; //Get record Id from process AppService appService = (AppService) AppUtil.getApplicationContext().getBean("appService"); String id = appService.getOriginProcessId(workflowAssignment.getProcessId()); //retrieve data FormRow row = new FormRow(); FormRowSet rowSet = appService.loadFormData(appDef.getAppId(), appDef.getVersion().toString(), formDefId, id); if (!rowSet.isEmpty()) { row = rowSet.get(0); //update field value row.setProperty(fieldId, fieldValue); } //Store the updated data rowSet.set(0, row); appService.storeFormData(appDef.getAppId(), appDef.getVersion().toString(), formDefId, rowSet, id); |
Code Block | ||
---|---|---|
| ||
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) {}
} |
...