import com.workbrain2.platform.apps.publ.api.workflow.WorkflowActionContext
import com.workbrain2.platform.apps.publ.api.workflow.WorkflowActionPublService
import com.workbrain2.platform.apps.publ.api.workflow.WorkflowActionPublicServiceAccess
import com.workbrain2.platform.apps.publ.api.workflow.WorkflowActionResponse
import com.workbrain2.platform.apps.publ.api.workflow.WorkflowActionScriptable
import com.workbrain2.platform.publ.api.exceptions.PublException
import static com.workbrain2.platform.publ.api.DebugPrint.*
class SampleWorkflowAction extends WorkflowActionScriptable{
WorkflowActionPublService workflowService
@Override
WorkflowActionResponse process(WorkflowActionContext context) {
debugprint("Begin processing workflow action")
workflowService = WorkflowActionPublicServiceAccess.getWorkflowActionService()
// Retrieving property from form
String stringProp = context.getProperty("string").get().toString("defaultString")
Boolean booleanProp = context.getProperty("boolean").get().toBoolean()
Date dateProp = context.getProperty("date").get().toDate("MM/dd/yyyy")
Long longProp = context.getProperty("long").get().toLong()
Double doubleProb = context.getProperty("double").get().toDouble()
try{
// Perform logic...
} catch (PublException e){
// if workflow action encountered an error, return an exception action response:
return workflowService.createActionResponseException("Failed to process workflow action:" + e.getMessage(),e)
}
// if workflow action processed successfully and has no error
return workflowService.createActionResponse(context,"SUCCESS","Workflow action successful.")
}
}