In this scenario our business requirement is that when an order is created you need to loop over all the items in the associated price list & create an order detail record for each product. This is a typical requirement when a company sells common sets of products together. So in their product catalog they create bundles of the commonly sold products together. So that when the user selects a price list it is the common bundle of products that they have selected.
Then when the formula executes (Order Creation) it creates one order line item record for each product in the price list and this saves the user a lot of clicks in picking out the individual products.
Please note that Dynamics 365 does have the concept of Kits which is similar to what we are trying to achieve here but these kits only appear as one sales order line item and so our method is far more flexible in that the user can easily remove unwanted line items.
Below is an example of a 'Silver Bundle' where when the Order was created the formula added in the two associated products automatically.
North52 Decision Suite Solution
The North52 Decision Suite solution works like this,
- We create a formula that fires on just the create event of an Order & it performs an action for us.
- The formula itself retrieves all the items on the associated price list & loops over each product
- As it loops it calls the create record function to create a Sales Order Detail record for each product
- The required fields are set on the sales order detail for each record.
North52 Decision Suite Steps
The following set of steps assumes you are just using the out of the box Dynamics 365 setup. But its easy to enhance if you have extra fields \ requirements.
- Create a new formula of type 'Save - Perform Action'
- Set the Event field to just 'Create'
- Set the Source Entity to 'Order'
- Set the Source Entity Property to 'Name' [Note: Needed due to Dynamics 365 firing multiple internal events]
- Copy & paste the formula below into the formula description field & click save
- You are ready to test
ForEachRecord( FindRecords('productpricelevel', 'pricelevelid', [salesorder.pricelevelid], 'productid'), CreateRecord('salesorderdetail', 1, SetAttributeLookup('salesorderid', 'salesorder', [salesorder.salesorderid] ), SetAttributeLookup('productid', 'product', CurrentRecord('productid') ), SetAttribute('quantity', '1' ), SetAttributeLookup('uomid', 'uom', FindValue('uom', 'name','Primary Unit','uomid') ) ) )
Wizard - FindRecords()
Did you know?
North52 helps you automatically test Dynamics 365 projects
North52's TestShield helps you test Dynamics 365 projects:
- FASTER - Our no code solution delivers automated CRM project testing faster
- EASIER - Simple to use point-and-click interface to build simple or complex testing plans
- SMARTER - Lower your project risk and slash ongoing costs with automated process testing