Call Subprocess
The Call subprocess action enables users to use existing processes inside another process (parent process). When a parent process calls a subprocess (a child process), it executes in a sequential manner. Once the child process completes, the execution control is then transferred to the main parent process.Β
Go to the Process Designers section and open a new or an existing process. Actions configuration can be performed once they are dragged and dropped on canvas.
Step 1.Β Drag the Call Subprocess action from Toolbar and drop it on canvas; click on the action to open the Properties Panel.
Step 2. Β You can edit the Action Name.
Step 3. Select the SubprocessΒ from a list of processes from your account.
Step 4. Click on the Subprocess configurationΒ card to go to the next configuration steps.
If the process (that is being called as a subprocess) has input and/or output process variables defined at process level, in the next step you must map the parent process variables to the child process variables (and/or vice-versa). This way, when the child process (subprocess) is executed, you ensure that data passes from the parent process to the subprocess (as input) and back to the parent process (as output).
Step 5. Mapping input/output process variables
Mapping all subprocess inputs and/or outputs to the parent's process variables is not mandatory.
- Input variables:Β
- you can map a parent process variable to subprocess input variables so that when the action is executed, data passes from the parent process to the subprocess.
- press +Add subprocess input and the selector will open displaying the subprocess input variables (if the subprocess has any input variables defined);Β
- on the left side, map it to a process variable coming from the parent process or give a default value (as applicable).
- Output variables:Β
- you can map a subprocess output variable toΒ the parent process variableΒ so that when the action is executed, data passes from the subprocess back toΒ the parent process.
- press +Add subprocess output and the selector will open displaying the subprocess output variables (if the subprocess has any output processΒ variablesΒ defined);Β
- on the left side, map it to a parent process variable.
For more details please check the below example:Β
Possible use case: A small shop keeps daily files with products sold and they want to send email confirmations to their customers. Instead of manually typing and sending a personal email to each customer, a one-time configuration of a process may help with automating this daily task. By simply running and uploading the daily file they have.
We have created 2 flows for our example.
1.Β Send email - template for customers:Β includes a Send email action configured which will send out emails to customers. This way you will not need to configure from scratch an action (or an entire process) that you may re-use. Simply by calling it in a Call subprocess action. This is theΒ child process.Β The child process will look like this:
To configure a Send email action you may checkΒ Send email action article.
The child process uses a process variable namedΒ inputdata. Inputdata is a data model with 4 attributes:Β to, subject, bodyDetails1, bodyDetails2.
These attributes used in the configuration of the Send Email action will receive data from the parent process at runtime.
2.Β Notify clients based on daily files:Β Gets data (related to customers and products they ordered) from the external .xls file and, for each entry in the file, will send confirmation emails to customers in the file, with details related to their order. Let's call this theΒ parent process. The parent process will look like this:
ο»Ώ
To configure the Get File Data action you may check theΒ Get File Data article.Β
Two process variables were created:
- getProducts (type list ofΒ orderedProducts); data model that matches the structure of the excel file that will capture the data from the file at runtime.
- productsList (type file; set as Input) that will fetch the file details at runtime.
In Get File Data, configure the Configuration panel as follows:
Next, in order to ensure that a separate email is sent to every entry in the file, a ForEach action is needed. CheckΒ For Each articleΒ for configuration details.
- Select the list to iterate through, i.e. getProductsο»Ώ
- Set the iterator name (you can name it iterator or row or entry etc)
Now let's configure the Call subprocess action:
Step1:Β Click on the action and the Properties Panel will open.Β
Step 2:Β Select a process you want to you within the main process. In our case, the process that has the template for sending email action we earlier configured.
Step 3:Β click on theΒ Subprocess configurationΒ card to move to the next configuration steps.
Step 4:Β To ensure that data is passed from the parent process (from the file) to the child process, you need to perform the data mapping for input and/or output process variables.
In our case, the process has no output variable as the only output of the process will be actually sending out the emails to the customers.
Mapping the subprocess input variables to variables coming from the process is important to ensure there is data to initiate the subprocess run.
The elements that are used in the Send email configuration in the child process (To, Subject, bodyDetails1, bodyDetails2) will receive data from the file (customeremail, orderid, productordered, totalAmountInvoice|)
As our action is inside a foreach border, use the iterator's attributes when mapping the data, not the attributes of the data model that captures the data from the file.
Step 5:Β Save, Validate and Run the Process. Upload the .xls file and click Run.Β
This is one sample of an email sent.
ο»Ώ