Scenario
A NetSuite administrator created an Inline HTML custom field intended to highlight a populated body field using HTML styling.
Example formula:
CASE
WHEN TRIM(NVL({custbody5}, '')) != ''
THEN '<div style="background-color:yellow; color:black; font-weight:bold;">'
|| {custbody5} ||
'</div>'
ELSE 'Empty'
END
However, even though {custbody5} contained data, the formula continued returning 'Empty' instead of the highlighted value.
Solution
Option 1: Use LENGTH() to Check for Values
In this formula, replacing the TRIM(NVL()) logic with a simpler LENGTH() check resolved the issue.
CASE
WHEN LENGTH({custbody5}) > 0
THEN '<div style="background-color:yellow; color:black; font-weight:bold;">'
|| {custbody5} ||
'</div>'
ELSE 'Empty'
END
This formula:
- checks whether the field contains text
- applies HTML formatting when populated
- displays “Empty” only when no value exists
Option 2: Use IS NOT NULL
Another approach is to check the field directly with IS NOT NULL.
CASE
WHEN {custbody5} IS NOT NULL
THEN '<div style="background-color:yellow; color:black; font-weight:bold;">'
|| {custbody5} ||
'</div>'
ELSE 'Empty'
END
This may work better depending on how the field stores blank values in your environment.
Notes
- Inline HTML fields are useful for visually emphasizing important transaction or entity information directly on forms.
- Some custom fields may technically contain hidden whitespace or formatting that can affect TRIM() and NVL() evaluations.
- In these cases, LENGTH() can sometimes behave more reliably for simple populated/not-populated checks.
-----
If you find this information useful, let us know by reacting or commenting on this post!