In this scenario when an order is marked as 'Fulfilled' we need to loop over each of the Order Line Items & decrement the 'Quantity On Hand' field on the product entity with the quantity on the Order line Item.
North52 Decision Suite Solution
The North52 Decision Suite solution works like this,
- We create a formula of type Process Genie so that it can be called from a workflow
- A workflow is created that checks when the order goes to a status of Fulfilled
- If it does go to Fulfilled then call the formula to loop over the order line items & decrement the quantity on hand from the product
North52 Decision Suite Steps
The following set of steps will set this formula up for you,
- Create a new formula of type 'Process Genie'
- Set the Source Entity to 'Order'
- Copy & paste the formula below into the formula description field
- Click Save
- Make a note of the formula short code in the top right hand corner of the formula. In this case 'ThY'
The following set of steps will set the workflow up for you,
- Create a new workflow based on the screenshot above
- Add a condition to check if the Order is Fulfilled
- If the condition is true then add the custom workflow activity named 'North52 Process Genie'
- Set the formula short code to ThY
- You are ready now to test
ForEachRecord( FindRecords('salesorderdetail', 'salesorderid',[salesorder.salesorderid],'*'), UpdateRecord('product', CurrentRecord('productid'), SetAttribute('quantityonhand', FindValue('product', 'productid',CurrentRecord('productid'),'quantityonhand') - CurrentRecord('quantity') )) )
Wizard - FindRecords
Did you know?
North52 Decision Suite helps streamline complex business processes
North52 Decision Suite is a cloud-based or on-premise decision management/decision engine platform for the Dynamics 365 and Power Platform that uses data, analytics and business rules to automate decisions.
Companies use North52 to streamline their processes, improve the quality of the decisions inside their Dynamics 365 systems, and shorten the time it takes to adjust to business and competitive changes.