Conditional Text Formatting in Easybadge Expressions

Modified on Fri, 23 Oct at 4:56 PM

EasyBadge allows you to dynamically change how field data looks on a card using conditional expressions. A common use case is changing text color based on a database value such as highlighting different access levels, cardholder types, or status codes.


This article walks through using the Iif (Immediate If) function alongside basic HTML tags to format fields dynamically.

The function can be added into the text box object of the card design.


Expression Fundamentals

The Iif Statement

The Iif function evaluates a condition and returns one outcome if the statement is true, and another if it is false:


Iif(Condition, True Outcome, False Outcome)


Combining Formatting with Fields

To apply styling to a field, concatenate (link together) the HTML style tag and your database field using the + operator:


"<font color=ColorName>" + FieldName


Practical Examples


Two-Condition Rule

Use this formula when you want to apply one color for a specific value and a default color for everything else.

Example Rule: If FieldName equals "ValueA", display text in red. For any other value, display text in green.


[Iif(FieldName = "ValueA", "<font color=red>" + FieldName, "<font color=green>" + FieldName)]



Nested Logic

When you need to handle multiple distinct values, you can nest Iif statements inside one another. EasyBadge evaluates each rule in order until it finds a match. If no conditions match, it falls back to the final default value.

Example Rule: Assign unique colors for four different values (ValueA, ValueB, ValueC, and a default for anything else).


[Iif(FieldName = "ValueA", "<font color=red>" + FieldName, Iif(FieldName = "ValueB", "<font color=green>" + FieldName, Iif(FieldName = "ValueC", "<font color=blue>" + FieldName, "<font color=orange>" + FieldName)))]


How it works:

Checks if FieldName is "ValueA" > Applies Red.

If not, checks if FieldName is "ValueB" > Applies Green.

If not, checks if FieldName is "ValueC" > Applies Blue.

If none match, applies Orange as the fallback.

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article