Difference between revisions of "Workflow call"

From Catglobe Wiki
Jump to: navigation, search
 
Line 29: Line 29:
 
==Syntax==
 
==Syntax==
  
Workflow_call(''workflowResourceId[, array parameters]'')
+
Workflow_call(workflowResourceId[, array parameters])
 +
 
 +
Workflow_call(workflowResourceId[, array parameters] [, schedule])
  
 
==Arguments==
 
==Arguments==
Line 36: Line 38:
  
 
''parameters'': will be passed into the CG Script of the called workflow or tabulation script
 
''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 class|CatTaskInstantSchedule]], [[CatTaskSpecificTimeSchedule class|CatTaskSpecificTimeSchedule]], [[CatTaskNeverSchedule class|CatTaskNeverSchedule]]
  
 
==Return value==
 
==Return value==
  
 
Object: This function returns a number, boolean, string, array, etc. depending on what the called workflow returns.
 
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==
 
==Example==
 +
<source lang="javascript">
 +
//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;
 +
</source>
  
'''Main script:'''
+
<span style="color:#DF8621"> Call workflow with parameters </span>
 
<source lang="javascript">
 
<source lang="javascript">
array parameters={100};
+
//Main script
number wfId = 12345;
+
number x = 100;
array a = Workflow_call(wfId,parameters);
+
array parameters = {x};
print(a);
+
number workflowRId = 12345;
 +
number result = Workflow_call(workflowRId, parameters);//result = 101
 
</source>
 
</source>
'''Script of worflow with Resource Id = 12345:'''
+
 
 +
<span style="color:#DF8621"> Schedule workflow, will return CatTask instance id </span>
 
<source lang="javascript">
 
<source lang="javascript">
array b = Workflow_getParameters();
+
number workflowRId = 12345;
b[0] = b[0] + 100;
+
number numberOfMinutesInFuture = 1;
return b;
+
CatTaskSpecificTimeSchedule whenToSchedule = new CatTaskSpecificTimeSchedule(new DateTime(DateTime_addMinutes(new DateTime().AsArray, numberOfMinutesInFuture)));
 +
number curSchedule = Workflow_call(workflowRId,{100}, whenToSchedule);//return CatTask instance id
 
</source>
 
</source>
'''The main script will print:'''
 
 
200
 

Latest revision as of 07:23, 27 May 2020



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