String processId = assignment.getProcessId();
// load form
Long appVersion = (appDef != null) ? appDef.getVersion() : null;
String formUrl = AppUtil.getRequestContextPath() + "/web/client/app/" + appId + "/" + appVersion + "/assignment/" + activityId + "/submit";
PackageActivityForm activityForm = appService.viewAssignmentForm(appDef, assignment, formData, formUrl);
Form form = activityForm.getForm();
// submit form
FormData formResult = formService.executeFormActions(form, formData);
if (formResult.getFormResult(AssignmentWithdrawButton.DEFAULT_ID) != null) {
// withdraw assignment
workflowManager.assignmentWithdraw(activityId);
return "client/app/dialogClose";
} else if (formResult.getFormResult(AssignmentCompleteButton.DEFAULT_ID) != null) {
// complete assignment
Map<String, String> variableMap = AppUtil.retrieveVariableDataFromRequest(request);
formResult = appService.completeAssignmentForm(form, assignment, formData, variableMap);
Map<String, String> errors = formResult.getFormErrors();
if (!formResult.getStay() && errors.isEmpty() && activityForm.isAutoContinue()) {
// redirect to next activity if available
WorkflowAssignment nextActivity = workflowManager.getAssignmentByProcess(processId);
if (nextActivity != null) {
String assignmentUrl = "/web/client/app/" + appId + "/" + appVersion + "/assignment/" + nextActivity.getActivityId();
return "redirect:" + assignmentUrl;