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.
How to configure the Call Subprocess action?
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.
Create the subprocess
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.
Create the main process
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.