Tuesday, 30 March 2021

Validation Rules in Salesforce

 Hello All, 

Very often we require to make system throw errors based on Values of Different fields.

i.e. Suppose field Purchase Type has value "Finance" then, Finance Stage and Financer must be filled else there should be error popup.









This can be configured with Validation Rules, and no Apex code is required for this, 

Lets see the steps for this,

1. Go to Setup -- Customize -- select the Entity to customize(Opportunity in my case) -- select Validation Rules











2. List appears for the validation Rules, here we need to write a New rule or Edit an Existing one.






3. Writing the Formula, 












we need to Give a meaningful name to the Rule, 

The expression builder is very user friendly, we can select the Field from Select Field Button, and Insert Operator button to Insert functions, 

Check syntax to validate the expression, and Provide the error message as desired.

Tips to write expression , 

to check if Finance field is  null 

ISBLANK() function can be used for this, as the name suggest it returns Y for Blank values 

to check if Finance Stage Picklist has null value

ISPICKVAL(Name,""), can be used as for picklist field we cannot use ISBLANK() function 

and then clubbing the Equation to be 

ISPICKVAL(Purchase_Type__c,"2-Finance") && (ISPICKVAL(Finance_Stages__c,"") || ISBLANK(Financer__c))

Which is equivalent to

IF (Purchase type = '2-Finance' AND (Finance Stage is NULL OR Financer is NULL))

this can be written to handle more complex cases see examples here 

https://trailhead.salesforce.com/content/learn/modules/advanced_formulas/picklist_formulas


2 comments:

  1. It’s my fortune to go to at this blog and realize out my required stuff that is also in the quality.
    white sweatshirt mens

    ReplyDelete
  2. Our digital marketing services are driven by thorough market research and industry analysis that provide a comprehensive understanding of your business

    ReplyDelete

Siebel GoTo View - Handling Realtime cases

 Hello All,  We all must have used GoTo view functionality of siebel to navigate to a particular view from current view. What if the require...