Skip to content
For the complete documentation index, see llms.txt. This page is also available as Markdown.

Customizing the Badge Color using a formula

Color the Stage column of a screen flow Data Table as badges, green for won and red for lost, driven by one formula field on Opportunity.

A sales manager reviews open deals in a screen flow before reassigning them. A gray column of stage names is slow to read. Shown as badges, Closed Won turns green, Closed Lost red, and late stages yellow, so the deals that need attention stand out at a glance.

The color comes from a text formula field on Opportunity. The Data Table reads it on every row and uses it as the badge variant.

Data Table of opportunities with the Stage column shown as colored badges: green for Closed Won, red for Closed Lost, yellow for late stages, blue for Needs Analysis, gray for Qualification
The Stage Variant formula picks the badge color of each row.

Before you start

  • A screen flow with an Avonni Data Table that lists Opportunities. If you are starting from scratch, follow Learn the Basics first.

  • The table uses the Query or Variable data source. See Data Source.

  • Permission to create fields in Object Manager.

Steps

1

Create the variant formula field

  1. In Setup, open Object Manager > Opportunity > Fields & Relationships > New.

  2. Choose Formula, name the field Stage Variant, and set the return type to Text.

  3. Paste this formula:

Every value the formula returns must be one of the badge variants listed in Badge variants, spelled exactly.

2

Make the field reach the table

  • Query data source: nothing to do, the field is available in the column settings.

  • Variable data source: the record collection comes from a Get Records element. Make sure that collection includes the Stage Variant field.

3

Turn the Stage column into a badge

  1. Select the Data Table on the screen and click Open Component Builder.

  2. In the preview, click the chevron on the Stage column header and choose Type Attributes.

  3. Set Type to Badge.

  4. Next to Variant, turn on the Field Name toggle so each row reads its own value from a field (how the toggle works). For Variant it shows a text box, not a field list: type the API name of the formula field, for example Stage_Variant__c.

  5. Click Save, then Done.

The badge text is still the stage name. Only its color comes from the formula.

4

Save and test

Save the flow and click Debug (or Run). Closed Won rows show a green badge, Closed Lost a red one, Proposal/Price Quote and Negotiation/Review a yellow one, the analysis stages an info badge, and Prospecting and Qualification the default gray badge.

Badge variants

These are the values the Variant attribute accepts. Your formula must return them exactly, in lowercase.

Value
Typical use

base

Default, neutral

brand

Highlight in the brand color

inverse

Strong emphasis

alt-inverse

Strong emphasis, alternative style

success

Won, done, approved

info

In progress

warning

Needs attention

error

Lost, rejected, overdue

offline

Inactive

Need a color that no variant gives you? The Badge type also has Background Color and Text Color. Both take the Field Name toggle too, so a formula field that returns a hex code (for example "#2E844A" for Closed Won) colors each badge exactly.

Troubleshooting

Every badge is gray
  • The formula returns a value that is not a variant name, or uses a different case (Success instead of success). Add the formula field as a temporary text column to see what each row returns.

  • With a Variable data source, the Get Records collection does not include the formula field, so each row has no variant.

  • Check the Field Name toggle next to Variant is on. With it off, the picker sets one fixed variant for the whole column.

One stage keeps the default color

CASE() compares the exact picklist value. Check the spelling in Setup (for example Id. Decision Makers with its period) and add the missing value to the formula.

Last updated

Was this helpful?