Views:

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)'


 

N52 Formula Manager Solution

The Formula Manager 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

N52 Formula Manager 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

Formula

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

            FindCount('opportunityproduct', 
                      'opportunityid', 
                      [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.