How to Add HTML Styled Comments Using Update Data Resource in UI Builder
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2025 02:34 AM
Hi everyone,
I'm working in ServiceNow UI Builder, and trying to update a record using the Update Data Resource triggered from a button's event handler. Specifically, I want to add a comment like this with HTML formatting:
html :<b style='color:red;'>Incident has been escalated</b>
Here's the script I'm using in the event handler:
/**
* @Param {params} params
* @Param {api} params.api
* @Param {any} params.event
*/
function evaluateEvent({
api,
event
}) {
if (event.payload.item.id === 'escalate') {
return {
table: api.context.props.table,
recordId: api.context.props.sysId,
templateFields: "comments=<b style='color:red;'>Incident has been escalated</b>"
};
}
}
But when the update happens, the comment is saved as plain text (i.e., the tags show up in the comment) instead of rendering as formatted HTML.
Is there a way to make the comment accept and render HTML formatting like bold/red text?
Any suggestions or best practices would be appreciated!
Thanks in advance!
#UI Builder
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2025 06:26 AM
@SaiShivaniS Try with [code] tag like below
[code]<b style='color:red;'>Incident has been escalated</b>[/code]
Hope this answers the query and if it does, please mark the answer as correct response.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2025 01:46 AM
@NeerajS57169215 I have added [code]<b style='color:red;'>Incident has been escalated</b>[/code] its not working if i remove style='color:red; then text its added as bold, my requirement is to add additional comments in bold and red color text.