Difference between revisions of "Workflow call"

From Catglobe Wiki
Jump to: navigation, search
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
[[Category:Workflow]]
 
[[Category:Workflow]]

+
{{HelpFiles}}
  
====Workflow_call====
+
=Workflow_call=
  
'''Description'''
+
==Description==
  
 
This function will allow you to run a specific workflow or tabulation script, including feeding it with parameters in the process.
 
This function will allow you to run a specific workflow or tabulation script, including feeding it with parameters in the process.
Line 27: Line 27:
 
* 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)
 
* 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'''
+
==Syntax==
  
Workflow_call(''workflowResourceId[, array parameters]'')
+
Workflow_call(workflowResourceId[, array parameters])
  
'''Arguments'''
+
Workflow_call(workflowResourceId[, array parameters] [, schedule])
 +
 
 +
==Arguments==
  
 
''workflowResourceId'': number - resource id of workflow
 
''workflowResourceId'': number - resource id of workflow
Line 37: Line 39:
 
''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
  
'''Return value'''
+
''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==
  
 
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.
  
'''Example'''
+
When schedule workflow, will return CatTask instance id
 
 
'''Main script:'''
 
 
 
''array parameters={100};''
 
 
 
''number wfId = 12345;''
 
 
 
''array a = Workflow_call(wfId,parameters);''
 
 
 
''print(a);''
 
 
 
'''Script of worflow with Resource Id = 12345:'''
 
 
 
''array b = Workflow_getParameters();''
 
 
 
''b[0] = b[0] + 100;''
 
 
 
''return b;''
 
 
 
'''The main script will print:'''
 
  
200
+
==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>
  
'''Availability'''
+
<span style="color:#DF8621"> Call workflow with parameters </span>
 +
<source lang="javascript">
 +
//Main script
 +
number x = 100;
 +
array parameters = {x};
 +
number workflowRId = 12345;
 +
number result = Workflow_call(workflowRId, parameters);//result = 101
 +
</source>
  
Version 5.8.1
+
<span style="color:#DF8621"> Schedule workflow, will return CatTask instance id </span>
__NOTOC__
+
<source lang="javascript">
<!-- imported from file: 8067.htm-->
+
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
 +
</source>

Latest revision as of 06: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