An automation triggers upon the creation of Order Product records. This automation generates Fulfilment records not just per line item, but for each unit within the specified quantity. For example, if an order contains a single line item with a quantity of 15, the system creates 15 individual Fulfilment records, one for each unit, since each needs to be fulfilled separately.
In order to solve this problem, We need to create a Record Triggered Flow and mimic a loop.
Let’s start by creating a new Record Triggered Flow
a. Go to Setup> Flows and click the New Flow button
b. Select Start From Scratch, Click Next, Choose Record Triggered Flow, and click Create
c. As the object, Select Order Product. Under Configure Trigger, Select A record is created
d. Under Set Entry Conditions, Set the dropdown to Formula Evaluates to True and set the Formula to
{!$Record.Quantity}<>0
Create Record Variables that we will use in Assignments inside our loop
a. Click on the symbol besides Select Elements and select New Resource
b. Select Variable as the Resource Type, Set the API Name to SingleFulfillmentVar, Set the Data Type to Record and the Object to Fulfillment Order and click Done
Add another New Resource
a. Select Variable as the Resource Type, Set the API Name to FulfillmentColl , Set the Data Type to Record and make sure you select Allow multiple values (collection) and set the Object to Fulfillment Order and click Done
b. We need one more variable that will allow us to count the number of records created
c. Once more, Click New Resource, Select Variable as the Resource Type, Set the API Name to Counter, Set the Data Type to Number and change the Decimal Places and Default Value to 0 and click Done
Add a Decision Element to the canvas by clicking the + sign just under the Start Element and choose Decision
Note : Give appropriate name for Decision Element and Outcomes
Note : Counter is a numeric variable, whereas $Record refer to the triggering record-in this context, the triggering Order Product
a. Name the Decision Element as Counter Check. For the Outcome use name Need Record. Update the Default Outcome to a more meaningful label, Such as No Record Needed
b. In the Need Record outcome, Set the filter to
| Counter | Does Not Equal | {!$Record.Quantity} |
In the Need Record branch, Add an Assignment Elements by clicking the + sign
a. Give it a appropriate Label and add values needed to create the Fulfillment Order records by using theb SingleFulfillmentVar created earlier
| SingleFulfillmentVar >AccountId | Equals | {!$Record.Order.AccountId} |
| SingleFulfillmentVar >OrderId | Equals | {!$Record.OrderId} |
b. Add another Assignment to the collection created earlier. and increment the counter by 1
| FulfillmentColl | Add | SingleFulfillmentVar |
| Counter | Add | 1 |
c. The Flow should look like this at the moment
: Now, click the + sign after the second Assignment and select Connect to element and click the + sign under the Decision Element
a. You should now see a connection between the last Assignment Element and the Decision Element
b. This allows the Decision to be again since the Counter value is now 1 more than the last time, so we keep evaluating it until the Counter is equal to the Quantity as per our Decision Outcome. When the Counter is equal to the Quantity, the Decision Outcome will be false and therefore we will go down the other Outcome path
Add a Create Records Element in the No need for any record outcome by clicking the + sign
.
a. Give it a appropriate Label, then set the How to set record field values dropdown to From a Record Variable. Set How Many Records to Create to Multiple and finally assign FulfillmentColl variable to the Record Collection field
Save the Flow and Activate it
004695536

We use three kinds of cookies on our websites: required, functional, and advertising. You can choose whether functional and advertising cookies apply. Click on the different cookie categories to find out more about each category and to change the default settings.
Privacy Statement
Required cookies are necessary for basic website functionality. Some examples include: session cookies needed to transmit the website, authentication cookies, and security cookies.
Functional cookies enhance functions, performance, and services on the website. Some examples include: cookies used to analyze site traffic, cookies used for market research, and cookies used to display advertising that is not directed to a particular individual.
Advertising cookies track activity across websites in order to understand a viewer’s interests, and direct them specific marketing. Some examples include: cookies used for remarketing, or interest-based advertising.