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 CRM 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.
N52 Formula Manager Solution
The Formula Manager 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.
N52 Formula Manager Steps
The following set of steps assumes you are just using the out of the box Dynamics CRM 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 CRM 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?
Over 300 customers use North52!
Join over 300 organizations worldwide who trust North52 to drive their digital transformation into the future:
Serious Power without Code: Easily build business rules, tests and data packages using our point-and-click editors. Even the most complex business rules are easily configured.
Build Fast: We’ve built the North52 tools with our user’s productivity in mind – up to 10x faster than writing custom code.
Awesome Support: We take pride in providing world class support to our customers and partners, ensuring you are successful with North52.
Future Proof: We ensure your business rules and tests that you configure today, will continue to work with the ever changing Dynamics 365 platform.