Wednesday, April 17, 2019

Custom Field with Font Styles

Scenario: The user wants to create a custom Transaction Body Field with font styles (different background color, text color) that varies depending on certain conditions.

Solution: The user can create an Inline HTML field that uses CASE WHEN formula with div tags to use for formatting.

Example: The user wants to display Text1 for condition #1 and Text2 if condition #1 is not met.

 

1.    Navigate to Customization > Lists, Records, & Fields > Transaction Body Fields > New.

2.    Type = Inline HTML

3.  Applies To tab > Select target record type.

4.    Validation & Defaulting tab > FORMULA = T > DEFAULT VALUE

CASE WHEN (insert condition/s) THEN '<div style="; background-color:yellow; color:black;font-weight:bold">' || 'Text1' || '</div>'ELSE'<div style="background-color:red; color:white;font-weight:bold">' || 'Text2' || '</div>'END


 

Sample formula:

CASE WHEN {custbody1} = 'Approved' THEN '<div style="; background-color:yellow; color:black;font-weight:bold">' || 'APPROVED' || '</div>'ELSE'<div style="background-color:red; color:white;font-weight:bold">' || 'REJECTED' || '</div>'END

 

Output:

If custbody = Approved, value of custom field is APPROVED.

If custbody is not Approved, value of custom field is REJECTED.

No comments:

Post a Comment