Formula Field & Validation Rule in Salesforce

Formula Field & Validation Rule in Salesforce

Sharing is caring!

Salesforce is basically a Cloud Computing CRM (Customer Relationship Management) tool where customer database is maintained in a proper format.

Many of you might have come across the terms – Formula field and Validation Rule.  In this blog, we are going to cover these 2 very useful aspects of Salesforce – Formula field & Validation Rule.

Perhaps the very first and basic question that arises here is, ‘What is a Formula?’

What is a Formula?

Formula, simply is a field type. It can be completely independent or it might take reference from some field. For example, if one is selling Cricket bats and he/she wants to associate a Service Tax of 15% with it. Now, we all know that Tax needs to be calculated on the Actual Price, here in this case, let’s say that has been entered in a Field called Amount. Once a formula for the same is written, values would be calculated and updated automatically by Salesforce.

Formula field

Formula field is a read only field, whose value is evaluated from the formula or expression defined by user. As far as its application is concerned, Formula field can be defined on both – Standard & Custom Objects. Formula field has values which change or get updated, as soon as there is any change in the expression or formula. Thus, users through application of few conditions and calculations can manipulate the values stored in Formula field as per their need.

NOTE

Working with Formulas, user might come across Syntax errors at times. To debug the formulas, a very important tool is the Check Syntax button that tells you about the error and its location.

Importance of Formula field

Customer centricity, in terms of ease of understanding and accessibility, lies at the core of the concept of Salesforce. With the same spirit, let us try to understand the use of Formula in Salesforce. Let us take the following example for a better understanding.

Mr. A is a client to a firm, XYZ working in Salesforce landscape.  Now, XYZ has a huge bunch of data with it, which is related to Mr. A’s business. Mr. A wants to understand some of the data trends and get an insight into the current situation of business. However, Mr. A wants to avoid the complex calculations ought to be done to reach out to a conclusion or get desired results. This is where Formula field eases out the process and put things in perspective.

Basically, Formula fields are tools through which one can ensure the ease of understanding for the clients by controlling the way in which the data is being displayed.

Let us learn about the Steps to create Formula field.

What are the Steps to Create a Formula Field?

  • Go to Setup Menu
  • Click on Accounts
  • Click on Fields
  • Click on Customize
  • Select  New from Account Custom Fields and Relationship section
  • Select Formula (Field Data type)
  • Click on Next
  • Assign Field Label for Formula
  • Select Return Type (Numbers, Currency et cetera)
  • Create Formula by Selecting Field from Field Selector or typing in, if we know actual Field Name and using required Operators from Insert Operator
  • Click on Check Syntax to Validate
  • Click on Next
  • Establish Field Level Security. Click on Next
  • Add to Page Layouts
  • Click on Save

Moving on to another very important aspect of Salesforce, we would try to get a deep insight into Validation Rule.

Validation Rule

Validation Rule as the name suggests, validates or verifies whether the data entered by user in records,  meet the specified standards before the user saves it. Technically, Validation rule in Salesforce contains a formula or expression that evaluates the data in one or more fields in a record to meet the standards and return a value “True” or “False”.

Moreover, Validation rule displays error message to the user when the condition is “True”. This means no record would be saved when the specified criteria is not met, and the user attempts to save the record. The error message can also be defined by the user. In broader terms,

Furthermore, Validation rule helps to avoid storing of unnecessary data.For any Salesforce landscape business, Data is something that is very powerful and is quintessentially uncompromisable on quality, both for the user and the firm. Validation rule is an important aspect of Salesforce that ensures the ‘Data quality’.

Lastly, we are going to learn the Steps to create Validation rule

  1. From Setup, open the Object Manager and click Account object.Object can vary as per the user requirement.
  2. In the left sidebar, click Validation Rules.
  3. Click New.
  4. Enter the required properties for your validation rule.
  5. Provide Error message to be displayed.
  6. Click Check Syntax to check the formula used
  7. Click Save to finish

Examples of a Validation Rule

Let us look at few examples of Validation Rule:

  1. Description: For Validating the Account Number being numeric if not blank.
  2. Description: For Validating the Account Number being exactly seven digits if not blank
Salesforce™ Formulas Validation

3.Description: For Validating the account Annual Revenue neither being negative nor exceeding $100 billion.

Conclusion

In a nutshell, Formula Field is basically a read only field. Value of Formula Field is evaluated from the user-defined formula or expression on both standard and custom objects. Any change in the formula is automatically reflected in the value of formula field.

On the other hand, Validation rule verifies that the user entered data meets the specified standards in a record before the record can be saved by the user. Noticeably a validation rule can contain a formula or expression, which evaluates the data in single or multiple fields and returns a value of “True” or “False”. In case of an invalid value, Validation rules include an error message to display to the user.

Nitish Bharadwaj

Nitish Bhardwaj, a highly accomplished Salesforce Principal Consultant, is the Chief Information Officer with extensive experience in enterprise IT strategy & development, project contracting and negotiations, Business Relationship Management, and Budgeting and compliances. Nitish, a renowned Salesforce Certified Administrator and a CPQ specialist, is a person of great integrity, always keeps his commitments, and positive till the core. One of his amazing qualities is the calm and poise he exhibits even when facing difficult and stressful situations. He has the knack of reaching to the core of subject and possess the capabilities to make to the top. Nitish has done an excellent job of being completely in charge of some of the most technically challenging assignments and is a perfect blend of management and technical capabilities. Full of energy, Nitish is a very detailed oriented person with excellent follow-through, he is always open to assist other teams in understanding various projects requirements so that collaboration can happen in the best possible ways in an environment conducive for the business. A go-getter in his own true ways, Nitish is always ready to take up challenges and always demonstrates a rare quality of flexibility to allow for situational variances and also acts as a solution provider, as and when any issue or clarification request is brought to his notice. A great leader to his team, Nitish is both kind and compassionate while having a firm eye on the end target."

This Post Has 5 Comments

  1. Love the insights in this post. Cannot wait to put them to good use.

  2. Just one word… Inspired.

  3. Thank you so much for the important information you provide.

  4. Keep carrying on and keep posting more.

  5. Thanks, I enjoyed reading this article.

Leave a Reply

Close Menu