Blockers with “Formulas and Validations” Module

Amit Kumar
7 min readApr 1, 2022

Tailor your apps by using point-and-click logic

Photo by Max Fischer: https://www.pexels.com/photo/photo-of-woman-standing-in-front-of-blackboard-5212320/

Hello fellow Trailblazers, welcome back.

Today, we are going to discuss the blockers with the “Formulas and Validations” Module. If you are pursuing any of the following trails-

  1. Admin Intermediate
  2. Developer Beginner

or if you are working to attain the “Process Automation Specialist” Superbadge, then you must complete this Module.

Formula and Validations

There are 3 units in this module and if you’re stuck in any of them and want to attain the above badge then please follow along. In this blog, I am going to discuss the blockers and their resolutions for these units.

So, let’s proceed.

Unit 1- Use Formula Fields

Formula Fields are Read-Only fields that automatically generate values according to the values present in other fields of the record. You can create a formula field in any object, just like you create a normal field.

Steps to create a formula field.

  1. Select the Object from Object Manager in Setup.
  2. Click on Fields and Relationships and click on New.
  3. Choose “Formula” from the available Data Types and Click Next.
  4. Provide a Field Label for the formula (Field Name is Auto-generated).
  5. Choose a return type of the formula field and Click next to provide the formula.

Now from the formula editor, you can provide the formula for the field that you have created.

As shown in the module a formula editor has

  1. Simple Formula/Advanced Formula- A simple formula has limited fields and Functions can’t be used in it whereas Advanced Formula has more number of fields as well as Formula Functions.
  2. Insert Field- This button can be used to insert fields in the formula. You can also use fields from Related objects if you are using Advanced Formula.
  3. Insert Operator- This drop-down menu can be used to insert operators in the formula, Advanced formula options provide a wider range of operators.
  4. Functions- This picklist can be used to insert Functions (Predefined Operations) in the formula. It is only available with the Advanced Formula option.
  5. Formula Editor- This is the place where you will create and edit the formula for the formula field.
  6. Check Syntax- This button is used to verify whether the written formula has any error in the syntax or not.

This unit is asking us to “Create a formula field that calculates the number of days remaining before a contract expires.”

NOTE- For being on the safe side I usually use a brand new Trailhead Playground for my modules and will suggest the same, but in case if you’re using an Old Playground, then try to use one in which you haven’t modified the Contract Object.

Steps to complete the module.

  • Click on Object Manager and go to Contract Object. [Make sure it’s Contract and not Contact]
  • Click on the “Fields & Relationships” option and Click New.
  • Choose Formula as Data Type and click Next.
  • Provide “Days Remaining” as Field Label and Choose Number as the return type.

Now, we have to calculate the Days remaining for the contract to expire and I would suggest using Advanced Formula here as the Contract End Date field won’t be available in Simple Formula. So after selecting Advanced Formula click on Insert Field and you will get the field as shown below.

and then today’s date must be subtracted from this date as the Contract End Date should Ideally be greater than today. To do that use the TODAY() function which you can type or even insert from the Functions Picklist. After that, you can check the syntax and your formula should look like -

Now, click Next, Next and Save and you are ready to check the challenge.

Unit 2- Implement Roll-Up Summary Fields

Now, as the name suggests we are going to create a roll-up summary field in this unit. A Roll-up Summary field actually aggregates the result from all the child records to the parent record and hence a Roll-up summary field can only be created on the Parent Object of the Master-Detail Relationship.

It is also created just like a normal field with a restriction that it is only possible on the Parent object of an MD Relationship and we have to select the return data type and aggregate function for the Roll-up. If we want we can also provide a filter to roll-up filtered records from the available child records.

In this unit, it is asked to “Add a custom field to the standard account object to provide a roll-up summary of the total expected revenue from all related opportunities.”

NOTE- If you have Advanced Currency Management enabled in your Trailhead Playground, disable it for this Hands-On Challenge.

To disable advanced currency management:

  1. From Setup, enter Manage Currencies in the Quick Find box, then select Manage Currencies.
  2. Click Disable.
  3. When prompted, select Yes, I want to disable Advanced Currency Management and click Disable.

Now let’s move on to the challenge.

  • Click on Object Manager and go to Account Object.
  • Click on the “Fields & Relationships” option and Click New.
  • From the available Data Types Click on “Roll-Up Summary” and click Next.
  • Provide “Potential Value” as Field Label and Click Next.
  • From the Summarized object, select “Opportunities”, choose Sum in the Roll-up Types and choose “Expected Revenue” as the field to aggregate.

Now, click Next, Next and Save and you are ready to check the challenge.

Unit 3- Create Validation Rules

Now, in this unit, we need to create a validation rule. Validation Rules are created to restrict some sort of record creation and editing. With Validation Rules, we can specify conditions that will stop the record creation or editing when the condition is true and show some sort of error.

These conditions are known as error formulas and we want these conditions to be false when we don’t want to restrict the user to create or edit the record.

In this unit, we are asked to “Create a validation rule that displays an error message and prevents a user from creating or updating a contact if two conditions are both true.”

Basically, we want that any related contact should have a mailing zip code similar to the related account’s shipping zip code.

So, to complete the challenge-

  • Click on Object Manager and go to Contact Object. [Make sure this time its Contact and not Contract]
  • Click on the “Validation Rules” option and Click New.
  • Provide “Contact_must_be_in_Account_ZIP_Code” in the Rule Name.

Now in the formula, as there are two conditions,

  1. Contact should be related to the Account.
  2. Mailing Zip Code and Shipping Zip Code should not be different.

Hence we will use AND function so that error should be displayed when both the condition are true. The formula should look like this-

AND(NOT(ISBLANK(AccountId)), Account.ShippingPostalCode <> MailingPostalCode)

Make sure the ShippingPostalCode is an Account field so you can find it under Account as shown below.

Don’t forget to provide an Error Message which can be anything but please give a meaningful error message. I have given the following error message.

“Contact’s Mailing Postal Code should be the same as of Account’s Shipping Postal Code.”

Now click on Save you are ready to check the challenge and attain the badge.

Congratulations!

Congratulations!!!

Don’t forget to leave your comments and give a clap to the blog, if you find it helpful.

Thank you so much

You can follow me on -

LinkedIn| Facebook | Twitter

--

--

Amit Kumar

4x Salesforce Certified, Developer, Trainer, Author and amateur Poet Mostly writes about Salesforce Technologies, Latest Releases & programming Languages…