Workflow call
Workflow_call
Description
This function will allow you to run a specific workflow or tabulation script, including feeding it with parameters in the process.
The function will throw an exception when:
- It is passed an invalid number of parameters
- It is passed invalid data types for any of its parameters
- It is passed empty parameters
- It is passed an invalid workflow resource id
- It is run by a user who does not have at least observer access to the workflow.
This function is useful in regards to:
- Returning values from a workflow that you need in another workflow
- Returning a chart from a tabulation script that you need in another workflow
- Returning the error stacktrace from another workflow
The following limitations apply to this function
- It cannot call a workflow which is set to run in batch mode
- It cannot run to a call depth of more than 10 (meaning that it cannot call a workflow that calls a workflow that calls a workflow ... to more than the 10th level)
Syntax
Workflow_call(workflowResourceId[, array parameters])
Workflow_call(workflowResourceId[, array parameters] [, schedule])
Arguments
workflowResourceId: number - resource id of workflow
parameters: will be passed into the CG Script of the called workflow or tabulation script
schedule: Use the given schedule to run workflow. It is CatTaskSchedule object see more at CatTaskInstantSchedule, CatTaskSpecificTimeSchedule, CatTaskNeverSchedule
Return value
Object: This function returns a number, boolean, string, array, etc. depending on what the called workflow returns.
When schedule workflow, will return CatTask instance id
Example
//Script of workflow with Resource Id = 12345
array para = Workflow_getParameters();
number a = para[0];//100
number b = 1;
number total = a+b;
return total;
Call workflow with parameters
//Main script
number x = 100;
array parameters = {x};
number workflowRId = 12345;
number result = Workflow_call(workflowRId, parameters);//result = 101
Schedule workflow, will return CatTask instance id
number workflowRId = 12345;
number numberOfMinutesInFuture = 1;
CatTaskSpecificTimeSchedule whenToSchedule = new CatTaskSpecificTimeSchedule(new DateTime(DateTime_addMinutes(new DateTime().AsArray, numberOfMinutesInFuture)));
number curSchedule = Workflow_call(workflowRId,{100}, whenToSchedule);//return CatTask instance id