Calling a Subprocess
Learn how to call a subprocess using the invoke keyword.
Introduction
In Kognitos, one way a parent process can call a subprocess is by using the invoke
keyword. When a subprocess is called this way, the parent process does not manage its execution. If multiple instances of a subprocess are invoked, they will execute sequentially, one after the other.
If you need to run subprocesses in parallel instead, see Starting Parallel Runs for details on using the start a run
syntax.
How Can I Call A Subprocess?
This section explains how to call a process within another process as a subprocess using the invoke
keyword.
Syntax
Input Parameters
subprocess name
: The name of the subprocess.inputs
: Any objects or variables the subprocess needs to run.
Example
In this example, the subprocess verify applicant qualifications
is called with the resume
as input.
Remember to Publish Your Process
You need to promote your automation from the Playground to a Process in order to call a subprocess. This applies to both the main process and the subprocess.
Returning Data from an Invoked Subprocess
To pass a result from a subprocess called with invoke
to the main process, you must add a line in both the parent process and the subprocess.
In the Subprocess
At the end of your subprocess, include one of the following lines:
For a single result:
the result is {result}
For multiple results:
the results are {result 1}, {result 2}, {result 3}, ...
If the results are not explicitly defined in this format, the parent process will not be able to access the subprocess output. By default, the parent process will only be able to retrieve the subprocess' status.
In the Parent Process
In the parent process, retrieve those results using get the answer
or get the answers
.
Example: Bakery Order Processing
Main Process
In this example, the main process process a bakery order calls the subprocess calculate the cost of a cake using the invoke
keyword. It passes three inputs. In the last line, get the answer
is used to retrieve the result from the subprocess and rename it to the total cake cost
.
Subprocess
The subprocess calculate the cost of a cake will perform calculations for the cake cost
and return it at the end using the result is the cake cost
.
Video Walkthroughs
1. Invoke a Process
This video shows how to invoke a process as a subprocess.
2. Using A Subprocess
This video demonstrates how to incorporate subprocesses within larger workflows.
Last updated
Was this helpful?