Java API Interface UserTask method complete(String outcome)

0
// This file was generated by Mendix Studio Pro. // // WARNING: Only the following code will be retained when actions are regenerated: // - the import list // - the code between BEGIN USER CODE and END USER CODE // - the code between BEGIN EXTRA CODE and END EXTRA CODE // Other code you write will be lost the next time you deploy the project. // Special characters, e.g., é, ö, à, etc. are supported in comments. package workflow.actions; import com.mendix.systemwideinterfaces.core.IContext; import com.mendix.webui.CustomJavaAction; import com.mendix.systemwideinterfaces.core.IMendixObject; import com.mendix.workflows.UserTask; import com.mendix.workflows.*; import com.mendix.core.Core; public class Java_API_Approve extends CustomJavaAction<java.lang.String> { private final java.lang.String taskId; private final java.lang.String action; public Java_API_Approve( IContext context, java.lang.String _taskId, java.lang.String _action ) { super(context); this.taskId = _taskId; this.action = _action; } @java.lang.Override public java.lang.String executeAction() throws Exception { // BEGIN USER CODE IContext context = getContext(); Workflows workflow = Core.workflows(); IMendixObject myObject = Core.retrieveId(context, Core.createMendixIdentifier(taskId)); UserTask task = workflow.getUserTask(context, myObject); Workflow w = task.getWorkflow(); UserTaskCompletionType type = task.getCompletionType(); if(task!=null) { //if(w.canRestart(){ //w.restart(); //} task.complete(action); return task.getKey(); }else{ return "error"; } // END USER CODE } /** * Returns a string representation of this action * @return a string representation of this action */ @java.lang.Override public java.lang.String toString() { return "Java_API_Approve"; } // BEGIN EXTRA CODE // END EXTRA CODE } I want to approve workflow in Java code. After passing TaskID and outcome, calling Java method cannot approve workflow, but can restart it. I want to know is there a problem with my parameters
asked
0 answers