Scenario Overview

In this scenario we have a business rule that needs to validate that when a user creates an Opportunity Product (line item) that only one record can exist per Opportunity when a specific price list is selected.

In the screenshot below you can see that the system stops the user from entering in a second line item because the Price List is set to 'CRM Service USA (sample)'


North52 Decision Suite Solution

The North52 Decision Suite solution works like this,

  • A server-side validation rule is set to execute when an Opportunity product record gets created
  • The formula first checks the price list to see if its the one we are concerned with 
  • And if so it then checks the existing count of line items
  • If this count is greater than or equal to one it will stop the create record and show an error message to the user

North52 Decision Suite Steps

The following set of steps outline how to create this Formula

  • Create a new formula of type 'Validation'
  • Set the Source Entity to 'Opportunity product '
  • Set the Mode to 'Server-Side'
  • Set the Source Property to 'All Properties'
  • Copy & paste the formula below into the formula 
  • Click save & test


if( FindValue('opportunity', 
               [opportunityproduct.opportunityid] , 
              'pricelevelidname')  = 'CRM Service USA (sample)'  and 

                      [opportunityproduct.opportunityid] ,
                     'opportunityid', '0', false) >= 1,

               'You can only have 1 line item if the parent 
                opportunities price list is set to CRM Service USA (sample) ', 

'NoOp' ) 

Wizard - FindCount

Please see below the wizard you can use to create the FindCount() function call used in this formula. 

Note to find the value for Equals Value, you will need to go to the Source tab and search for the value. 

Did you know?

North52 has a powerful distributed cache for advanced decision logic

xCache allows you to configure and scale your Dynamics 365/CRM applications running On-Premise or Online. It allows dynamic system configuration and removes performance bottlenecks related to data storage. xCache provides Dynamics 365/CRM with an extremely fast and scalable distributed cache to power your advanced decision logic.

xCache in Dynamics CRM  lets you cache static application data, and also load dynamic cache items for applications running in a single or multi-server configuration.

Learn more and see examples of xCache