Dynamic styling in NetSuite allows for a highly customizable and visually intuitive user interface, especially when using inline HTML fields. A common use case is visually distinguishing approval statuses within records by dynamically altering text color based on the status.
We need to create an inline HTML field that:
- Displays the approval status text.
- Shows the text in green if the status is “Approved.”
- Displays the text in red for any other status.
1. Create a Custom Formula Field
- Navigate to Customization > Lists, Records, & Fields >Transaction Body Fields (or the relevant record type for your customization).
- Click New to create a custom field.
- Set the following parameters:
- Label
- Type: Select Free-Form Text
- Applies To: Choose the record type where this field is required (e.g., transactions, vendors, etc.).
- In the Validation & Defaulting section, Check the Formula field and use the following in the Default Value field:
‘<h2 style=”color:’ ||
CASE
WHEN {approvalstatus} = ‘Approved’ THEN ‘green’
ELSE ‘red’
END
|| ‘:text-transforms: uppercase:”>’ ||
{approvalstatus} ||
‘</h2>’
Note:
The {approvalstatus} field is NetSuite’s standard Approval Status field. If we are using custom approval statuses, we will need to create a custom field to handle them and use its field ID in the HTML code instead.