Learning Objectives
-
Learn to use "Custom Action - Batch Data Source" to centrally process multiple data in a single process instance, avoiding repeated process triggering for each item.
-
Master the usage of Process Parameter Assignment to pass the unique identifier (e.g., Record ID) of a record in the main process to the process parameters of the subprocess, enabling accurate retrieval of the record in the subprocess.
-
Understand and apply one-by-one subprocess execution and "Search Result Branch" (Update if Exists, Create if Not) to realize conditional grouping and differentiated processing of data.
Scenario Case
To ensure the smooth progress of events, MEGA Company needs to provide unified catering services for employees and their visiting guests. Employees can submit their catering requests in the app, filling in information such as meal package and quantity. Some employees may have guests or clients accompanying them for meals, resulting in multiple catering requests. Every noon, logistics staff provide a unified catering order to suppliers. To improve catering efficiency and accuracy, MEGA Company hopes to achieve the following:
-
Logistics staff can check multiple catering request records at once and click a button to automatically merge them into one catering order, avoiding manual summarization.
-
Corresponding catering details are automatically generated in the catering order: the app groups requests by meal package package and summarizes the quantity of the same meal package into one detail. For example: Tom’s 2 portions and Lily’s 2 portions are both "meal package A", which are merged into "meal package A — 4 portions".
-
The catering order needs to be automatically written back and associated with each catering request, allowing employees to view the processing status and progress of their own catering requests in real time.
Operation Guide
Requirement Analysis
Merge to Generate One Catering Order
Configure a Custom Action button [Merge Catering] on the Catering Request worksheet. Check multiple records and click the button to execute the process, aiming to select multiple catering request records and enter the workflow.
Without additional settings, the default setting of Custom Action is to run the process multiple times (multiple process instances). Creating a catering order in each instance may lead to duplicates. If these multiple records can run in a single process instance, only one catering order will be created.
Therefore, via Custom Action - Batch Data Source, first create a catering order in the main process, configure a subprocess, and let the selected multiple catering request records enter the subprocess for execution one by one. Generate corresponding catering details in the subprocess and then associate them with the unique catering order record in the main process to achieve "merging to generate one catering order".
Merge and Group Requests of the Same meal package into One Catering Detail
After the main process successfully creates a catering order, it is necessary to automatically generate catering details based on different meal package packages. Since multiple catering requests may select the same meal package, grouping and quantity summarization are required. In this scenario, automatic merging of details is realized through "subprocess serial processing one by one + Search Result Branch (Update if Exists, Create if Not)".
|
Catering Request
|
Requester
|
Meal package
|
Request Quantity
|
|
1
|
Tom
|
meal package A
|
2
|
|
2
|
Lily
|
meal package B
|
2
|
|
3
|
Bob
|
meal package A
|
1
|
There are 3 requests in total. Among them, both Tom and Bob selected "meal package A", which need to be merged into one catering detail in the catering order, and the quantities are accumulated.
Subprocess Execution Logic One by One
These 3 catering requests serve as data sources and will enter the subprocess in sequence. The execution logic for each is as follows:
-
Catering Request 1 (Tom’s request) enters the subprocess:
-
Query whether there is a detail for "meal package A" under the catering order.
-
Query result: Does not exist.
-
Operation: Create a new catering detail with meal package A and Request Quantity 2.
|
Catering Detail
|
Meal package
|
Quantity
|
|
1
|
meal package A
|
2
|
-
Catering Request 2 (Lily’s request) enters the subprocess:
-
Query whether there is a detail for "meal package B".
-
Query result: Does not exist.
-
Operation: Create a new catering detail with meal package B and Request Quantity 2.
|
Catering Detail
|
Meal package
|
Quantity
|
|
1
|
meal package A
|
2
|
|
2
|
meal package B
|
2
|
-
Catering Request 3 (Bob’s request) enters the subprocess:
-
Query whether there is a detail for "meal package A".
-
Query result: Exists.
-
Operation: Update the quantity of the existing catering detail by adding Bob’s request quantity (2 + 1 = 3).
Final catering details table:
|
Catering Detail
|
Meal package
|
Quantity
|
|
1
|
meal package A
|
3
|
|
2
|
meal package B
|
2
|
Through the subprocess’s one-by-one processing mechanism combined with the "Search Result Branch" judgment logic:
This achieves the requirement of "automatic grouping of the same meal package and merging of quantities".
Application Configuration
Set Custom Action Button
Set a [Merge Catering] button on the Catering Request worksheet. The action is to execute a workflow, and the data source is multiple catering request records. Note that the filter condition for enabling the button should be set — it can only be enabled when the status of the catering request is "Not Ordered" to avoid duplicate orders.
In the workflow configuration, first create a new catering order record. The information of the selected catering requests will be merged into this form, and the order status will be set to "Pending".
After creating the catering order in the main process, configure a subprocess. Select [Catering Request] as the data object of the subprocess, and choose "Execute One by One" as the execution method to prevent data errors caused by parallel calculation when merging and grouping catering details by meal package.
Subprocess Process Parameter Assignment
Add process parameters to the subprocess, and pass the Record ID or other unique value field of the order form created in the main process. The purpose is to find the corresponding catering order record in the subprocess based on this unique value field.
Go to the Subprocess configuration page. The purpose of this Subprocess is to generate the Catering Details, merge identical Packages, and aggregate the quantities of each type of Package.
Retrieving the Package Form and Catering Order in the Subprocess
Within the Subprocess, the only data source is the Order Request record selected by the button. However, the Catering Details we need to generate must include information such as the Package name, unit price, and so on, and must be linked to the only newly created Catering Order in the main process.
Therefore, we first need to obtain the Package information for this catering request, that is, retrieve the Package Form associated with the Order Request.
Based on the Subprocess parameters configured earlier, filter by the record ID of the Catering Order to locate the newly created Catering Order in the Main Process.
Retrieve Catering Details: Update if Existing, Create if New
After retrieving the Package Form and the Catering Order, you can start checking whether there are existing Catering Details under this Catering Order that use the same Package as the current Catering Request. To do this, filter the data by Package and Catering Order.
If no related Catering Details are found, configure the node to add a new record to the Worksheet when no data is retrieved, and then execute. The newly created Catering Details record should be linked to the retrieved Package Formand Catering Order, and populated with the specific Package information such as Package name, unit price, and so on.
Update the Requested Package Quantity in the Catering Details
In the previous steps, we have retrieved or created the Catering Details and filled in the Package name and unit price. The final step is to merge the requested quantity for identical Packages.
Configure an Update Record node to increase the number of portions in the existing or newly created Catering Detailsrecord. The increment should be equal to the Requested Quantity from the Catering Request within the Subprocess.
Update the Status of Catering Requests in the Main Process
The Subprocess has now merged multiple Catering Requests selected by the button into a single Catering Order. When returning to the Main Process, update the Order Places Check Item of these Catering Requests to Yes, and link each request to the corresponding Catering Order.
Result
-
The App automatically generates a single Catering Order, merges identical Packages, and accumulates the total number of portions for each Package; at the same time, the Catering Order is associated with the corresponding Catering Requests.
Hands-on Practice
Now, click the "Open the Practice App" button in the upper right corner of the page to access the hands-on application designed for this course, and start practicing!