Reader small image

You're reading from  Salesforce for Beginners - Second Edition

Product typeBook
Published inOct 2022
PublisherPackt
ISBN-139781803239101
Edition2nd Edition
Concepts
Right arrow
Authors (2):
Sharif Shaalan
Sharif Shaalan
author image
Sharif Shaalan

Sharif Shaalan was first introduced to Salesforce as an end user in 2007. His range of experience, from a sales rep to technical architect, helped him successfully lead more than 100 implementations including projects that were showcased on the main stage at Dreamforce. In 2013, Sharif was chosen as a Salesforce MVP, and in 2020 he was inducted into the Salesforce MVP Hall of Fame. Sharif is a regular speaker at Salesforce conferences and has obtained more than 10 Salesforce certifications. He is the founder and CEO of Agile Cloud Consulting and continues to be an active Salesforce community contributor
Read more about Sharif Shaalan

Timothy Royer
Timothy Royer
author image
Timothy Royer

Timothy Royer is the VP of Delivery at Agile Cloud Consulting and a Salesforce Certified Application Architect. Timothy began his Salesforce career in 2012 as an accidental administrator and has since participated in a number of implementations in a variety of roles. Timothy has experience as a Salesforce customer, a Salesforce partner, and as a member of the Salesforce.org professional services team.
Read more about Timothy Royer

View More author details
Right arrow

Data Integrity with Formulas and Validations

Salesforce offers several features to ensure data integrity. Two of the most common features are formulas and validation rules. These tools help keep data trusted in two ways: formula fields eliminate the need for manual entry, and validation rules allow you to place rules around what data may be entered on a field or record.

In this chapter, we will cover the following data integrity features in detail:

  • Overview of formulas
  • Creating a formula field
  • Understanding validation rules
  • Creating a validation rule

With the help of these topics, you will be able to understand and create formulas and validation rules.

Technical requirements

For this chapter, make sure you log in to your development org and follow along as we walk through how to create formulas and validation rules.

Overview of formulas

Formulas are used to calculate custom fields and add logic to features such as validation rules and flows. Formulas calculate based on operators and functions.

The following operators and functions are available in Salesforce formulas. Using a combination of these results in a very powerful data integrity engine.

Below, we have provided screenshots of the different operators and functions categorized into different areas. First, we will see math, logic, and text operators; next, we will see date and time, logic, math, text, summary, and advanced functions. Have a brief look through the information below to get an idea of the tools you have available to you:

Note that you can view these operators and functions, and their relevant descriptions, at any time on Salesforce Help (see Further reading).

  • Math operators:

Figure 19.1: List of math operators available in Salesforce formulas

  • Logic operators:
  • ...

Understanding validation rules

Validation rules are an essential part of ensuring data integrity in Salesforce. They do this by verifying that the data your users enter into a record meets specific standards before the user can save a record. A validation rule can contain a formula or expression that evaluates the data in one or more fields and returns a value of True or False.

Validation rules can be included on any object.

Business use case

As the Salesforce admin for XYZ Widgets, you have successfully created the Account Level formula field. Since this field depends on the Annual Revenue and Employees fields being populated, you want to make sure users enter data into these fields when creating an account. To do this you will need to create a validation rule on the Account object.

Let’s take a look at how we can create this validation rule.

Creating a validation rule

To create the validation rule to meet this requirement we will follow...

Summary

In this chapter, we learned how formulas and validation rules help drive data integrity. We looked at available functions and operators and built a formula field to demonstrate a business use case for data integrity on the Account object. We then discovered what validation rules are and how they contribute to records having complete data. Finally, we built a validation rule that included a formula and met the requirements of our business use case.

In the following chapter, we will cover user management and data security.

Questions

  1. Where are three places where formulas can be used?
  2. What are the three components used when building a formula?
  3. What does a simple formula allow you to do?
  4. When do you treat blanks as zeroes?
  5. What results do validation rule formulas always return?
  6. When do you show the error on the top of the page versus on the field?

Further reading

Join our community on Discord

Join our community’s Discord space for discussions with the authors and other readers: https://packt.link/rlptF

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Salesforce for Beginners - Second Edition
Published in: Oct 2022Publisher: PacktISBN-13: 9781803239101
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Authors (2)

author image
Sharif Shaalan

Sharif Shaalan was first introduced to Salesforce as an end user in 2007. His range of experience, from a sales rep to technical architect, helped him successfully lead more than 100 implementations including projects that were showcased on the main stage at Dreamforce. In 2013, Sharif was chosen as a Salesforce MVP, and in 2020 he was inducted into the Salesforce MVP Hall of Fame. Sharif is a regular speaker at Salesforce conferences and has obtained more than 10 Salesforce certifications. He is the founder and CEO of Agile Cloud Consulting and continues to be an active Salesforce community contributor
Read more about Sharif Shaalan

author image
Timothy Royer

Timothy Royer is the VP of Delivery at Agile Cloud Consulting and a Salesforce Certified Application Architect. Timothy began his Salesforce career in 2012 as an accidental administrator and has since participated in a number of implementations in a variety of roles. Timothy has experience as a Salesforce customer, a Salesforce partner, and as a member of the Salesforce.org professional services team.
Read more about Timothy Royer