Inconsistent Line Break Behavior in System UI Messages (sys_ui_message) – Clarification Needed

Mohamed_009
Tera Contributor

We have observed inconsistent behavior with line breaks in System UI Messages (sys_ui_message) in ServiceNow.

  • In one scenario, line breaks are not displayed unless <br> tags are explicitly added in the message text.
  • In another scenario, line breaks are rendered correctly even without using <br> tags.

 

Due to this inconsistent behavior, it is unclear what the recommended or correct approach is when defining UI messages.

Could anyone help clarify:

  1. What causes this difference in behavior?
  2. Is using <br> tags the recommended best practice for multiline messages in ServiceNow?

 

2 REPLIES 2

Tanushree Maiti
Mega Patron

Hi @Mohamed_009 

 

refer this KB: KB1005865 Unable to translate if the 'sys_ui_message' if the key has '\n' it from VA Designer. 

 

Can you try with this resolution:

Resolution

  • The gs.getMessage call sends the text correctly.
  • To get a new line to work in scriptable form, you need to add another escape character in the script.

For example :

  • Suppose if the sys_ui_message has the key with 'hello \n world' the script portion to get a hit on this key needs to be 'gs.getMessage('hello \\n world');
  • This will hit that desired 'sys_ui_message' and this is not designer behavior but the platform.
  • The same behavior is expected when running in background scripts on the platform.
gs.getInfo(gs.getMessage('hello \\n world'))
Please mark this response as Helpful & Accept it as solution if it assisted you with your question.
Regards
Tanushree Maiti
ServiceNow Technical Architect
Linkedin:

Ankur Bawiskar
Tera Patron

@Mohamed_009 

share screenshots where are these messages rendered and how you configured those

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