Admins / Consultants

Your Guide to Conditional Formatting for Salesforce Fields

By Christine Marshall

Conditional formatting is a fun, new feature in Salesforce that allows users to visually distinguish key data points on record pages. By applying rulesets to fields, you can enhance data visibility, streamline workflows, and enable faster decision-making. 

This article explores what conditional formatting for Salesforce fields entails and provides a detailed tutorial on setting it up for a practical use case. 

What Is Conditional Formatting for Salesforce Fields?

Conditional formatting for Salesforce fields is a feature in the Lightning App Builder that allows you to customize the appearance of fields on record pages based on specific conditions. 

This customization can involve adding icons, colors, or text styles to make critical data stand out. The feature works with Dynamic Forms-enabled pages and is managed through rulesets – collections of conditions that control when and how formatting is applied.

Key benefits include:

  • Enhanced data visibility: Highlight crucial data to ensure it’s easy to find.
  • Improved productivity: Help users quickly identify important information.
  • Dynamic customization: Use flexible conditions based on field values or related criteria.

Whether it’s highlighting urgent tasks or flagging high-value opportunities, conditional formatting helps your team make informed decisions faster.

How to Set Up Conditional Formatting

In this tutorial, we’ll walk through how to configure conditional formatting for a specific use case: displaying a smiling face, neutral face, or sad face based on the Amount field. The formatting will:

  • Show a red sad face if the amount is under $10,000.
  • Show an orange neutral face if the amount is between $10,000 and $99,999.
  • Show a green happy face if the amount exceeds $100,000.

Prerequisites:

  • A Salesforce environment with Lightning App Builder enabled.
  • A record page that supports Dynamic Forms.

Step 1: Open Lightning App Builder

  1. Navigate to Setup in Salesforce.
  2. Search for App Builder in the Quick Find box.
  3. Open the Lightning App Builder and select the record page you want to customize.

Step 2: Add Conditional Formatting

  1. Click on the Amount field on the page layout canvas.
  2. In the property panel on the right, locate the Conditional Formatting section.
  3. Click into the box that says Select a ruleset and + Create Ruleset to create a new ruleset.
  4. Give your ruleset a name.

Step 3: Define Your Rules

  1. Create Rule 1:
    • Action: Choose the sad face icon and change the color to red to highlight the field.
    • Condition: Set Amount LESS THAN 10,000.
    • Click Next.
    • Click + Add Rule.
  1. Create Rule 2:
    • Action: Choose the neutral face icon and change the color to orange to highlight the field.
    • Condition: Set Amount GREATER THAN OR EQUAL 10,000 and Amount LESS THAN OR EQUAL 99,999.
    • Click Next.
    • Click + Add Rule.
  1. Create Rule 3:
    • Action: Choose the happy face icon and change the color to green to highlight the field.
    • Condition: Set Amount GREATER THAN OR EQUAL 100,000.
    • Click Next.
    • Click Save Ruleset.

Step 4: Save and Activate

  1. After configuring the ruleset, click Save to store your changes.
  2. Activate the record page layout if it isn’t already active.

Step 5: Test Your Formatting

  1. Go to a record that uses the field you applied conditional formatting to.
  2. Adjust the Amount field value to see the conditional formatting in action.

Top Tips

  • You choose the field to apply conditional formatting to (in the example above, the Amount field) but your formatting rules can use the value of other fields. So, if I am adding conditional formatting to the Amount field, my conditions could be based on another field value such as the Close Date or Stage. 
  • You must choose from the list of icons. You cannot add your own which is a bit disappointing. Originally I wanted to create conditional formatting to show 1, 2, or 3 dollar signs depending on the amount, but this was not possible.
  • You can add multiple conditions and logic, including custom logic such as 1 AND 2 AND (3 OR 4).
  • A field can only have one ruleset at one time but many rules. Rules are executed in the order you create them and as soon as a rule evaluates to TRUE, all remaining rules are ignored. You can’t reorder your rules after creation so be sure to add them in the right order. 
  • You have to edit the individual rule to delete it.
  • You can have up to 10 rules per ruleset. 
  • You can delete an entire ruleset from Conditional Field Formatting on the object.

Best Practices for Conditional Formatting

  • Keep it simple: Avoid overloading pages with too many visual cues to maintain clarity.
  • Test extensively: Check formatting under various conditions to ensure accuracy.
  • Collaborate: Work with stakeholders to define meaningful rules that enhance usability.

Considerations for Conditional Formatting

  • Edit: You can edit your configured rulesets.
  • Delete: You can delete your configured rulesets.
  • Rename: The ability to rename a ruleset is not yet available, but it is on the roadmap. 
  • Dynamic Forms: This functionality is only available for Lightning Experience-enabled orgs and on a record page that supports Dynamic Forms.

Summary

Conditional formatting for Salesforce fields transforms static record pages into visually exciting, user-friendly interfaces. Following this tutorial, you can easily set up rules that highlight critical data and make Salesforce a more intuitive tool for your users.

What use cases do you have for conditional formatting for fields in your org? Let us know in the comments!

The Author

Christine Marshall

Christine is an 11x certified Salesforce MVP and leads the Bristol Admin User Group.

Leave a Reply

Comments:

    Bart
    December 11, 2024 12:56 pm
    Indeed, this is really a nice feature! Finally I can remove quite a lot formula fields that referred to an image. However, there is a bug. When setting conditions, you can only select from around the first 200 fields available in an object. See: https://issues.salesforce.com/issue/a028c00000zj8ZcAAI/conditional-field-formatting-ruleset-has-truncated-list-of-fields This will be fixed in the Spring '25 release.
    Sarah
    December 12, 2024 6:04 pm
    This is great! I just wish there was an option for formatting if the field is empty/blank/null.
    Thomas
    December 15, 2024 9:16 am
    Maybe good to know there seems to be issues while deploying. I did not manage to deploy the ruleset yet.
    CG
    December 15, 2024 1:26 pm
    This is nice! Is it possible to add criteria for null values? I can't find a way to do this.
    Jodie Miners
    December 15, 2024 11:58 pm
    This is a great feature and very welcome. However it is very limited, and only has a few icons, and the icon positioning looks quite weird. For a really extensive and customisable way to highlight the important data on your record, I encourage you to try out Salesforce Indicators on the Appexchange https://appexchange.salesforce.com/appxListingDetail?listingId=192aeb3a-1476-4028-a25c-954d48560eba. Salesforce Indicators is part of the Salesforce Open Source Commons which is apps that are built by the Salesforce community for the Salesforce community, and you can be involved in the future direction of the app too!
    Dharmendra Bhuva
    December 19, 2024 9:06 am
    How to deploy this conditional formatting? It seems that it is not getting deployed with the lightning record page.
    Adam
    January 24, 2025 8:54 am
    From a Knowledge article on this: "Conditional formatting rulesets aren't automatically included when you add a Lightning page to a change set. If you create an outbound change set with a Lightning page that contains conditional formatting, make sure to add all of the page's conditional formatting rulesets to the change set. Conditional formatting rulesets are listed as "UI Format Specification Set" in the change set Component Type dropdown." https://help.salesforce.com/s/articleView?id=platform.conditional_formatting_considerations.htm&type=5 There's also a note in there about it handling "empty" numerical fields as zeros for people asking about null/blank treatment. I was looking for a blank text solution but still haven't found anything viable.
    Ryan
    April 26, 2025 7:06 pm
    Thank you for mentioning this! Searching for what I was missing led me to your comment.