how to set the Worknotes value in red color via business rule

Dany Rohinth
Tera Contributor

Hello folks,

I am trying to set the Work Notes field in red color using a Business Rule or any other method in ServiceNow. I've attempted a few solutions involving HTML tags and styles, but the text is not rendering as expected.

Could anyone provide guidance on the following?

  1. Business Rule Approach: How can I apply red color styling directly in the Work Notes field using a Business Rule? Any examples of how to inject the HTML properly would be very helpful.
  2. UI or Notification Approach: Are there any ways to modify the UI or Activity Stream so that the Work Notes appear in red color based on certain conditions?

I've already tried the following:

  • Using <span style="color: red;">Text</span> inside the Business Rule but it doesn't seem to work as expected.
  • Investigating the sys_ui_style table, but the field still does not reflect the red color.

Any assistance or examples would be greatly appreciated!

Thank you!

2 ACCEPTED SOLUTIONS

Ankur Bawiskar
Tera Patron
Tera Patron

@Dany Rohinth 

this will work-> to allow html tags you need to add [code] tag

(function executeRule(current, previous /*null when async*/) {
    var redText = '[code]<span style="color:red;">This is a red color text</span>[/code]';
    current.work_notes = current.work_notes + '\n' + redText;
})(current, previous);

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

@Dany Rohinth 

No worries.

Each day brings new lessons.

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

4 REPLIES 4

Ankur Bawiskar
Tera Patron
Tera Patron

@Dany Rohinth 

this will work-> to allow html tags you need to add [code] tag

(function executeRule(current, previous /*null when async*/) {
    var redText = '[code]<span style="color:red;">This is a red color text</span>[/code]';
    current.work_notes = current.work_notes + '\n' + redText;
})(current, previous);

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Hi Ankur,

Thank you for taking the time to provide such a detailed response—I truly appreciate it. The approach you suggested using the [code] tag is insightful and a great suggestion. Unfortunately, it didn’t work as expected in my case. The Work Notes field still does not render the HTML in red color in my environment, possibly due to specific instance configurations or restrictions on how journal fields handle HTML tags.

If you have any additional suggestions or insights, I’d be happy to explore them further. Thanks again for your support and efforts in helping me!

 

 

 

Best regards,
Dany Rohinth

 

Hi @Ankur Bawiskar ,

I hope this message finds you well.

I wanted to sincerely apologize for my earlier reply regarding the HTML rendering issue in the Work Notes field. Upon revisiting the setup on my end, I realized that the issue was due to an oversight in my implementation. The code you provided works perfectly, and I deeply regret any confusion my initial response may have caused.

Thank you for your patience and the detailed guidance you shared—it was indeed spot-on. I truly appreciate your expertise and the time you took to assist me.

Once again, I’m sorry for the misunderstanding, and I’m grateful for your continued support.

DanyRohinth_0-1733655118338.png

 

Best regards,
Dany Rohinth

@Dany Rohinth 

No worries.

Each day brings new lessons.

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader