Client Script not showing variable message on new line
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-07-2025 04:34 AM
In a client script, I’m trying to display a message on a variable field with line breaks (using <br> or \n). But the message appears in a single line. Is there a ServiceNow-supported way to render messages with new lines or styled HTML in catalog items?
Instead on writing 3 new g_form.showMessage('cc', 'My message');
is there any way to insert a new line in long description?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-07-2025 04:36 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-07-2025 04:39 AM - edited 07-07-2025 04:50 AM
Hello @Prudhvi Potru ,
Have you used " g_form.showFieldMsg('your_variable_name', 'message1', 'message2',...);" ?if not please try this if you want msg exact below the variable. It will display witout HTML
If want HTM Tags, You can use g_form.addInfoMessage() or g_form.addErrorMessage() to display messages at the top of the catalog item form. As it supports HTML.
function onLoad() { var message = 'This is a first Message.<br>This is the <b>second</b>Message.'; g_form.addInfoMessage(message); }
Thank you!!
Dnyaneshwaree Satpute
Tera Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-07-2025 04:46 AM
g_form.showFieldMsg() doesn't support HTML tags such as <br/> so you cannot add new line.
the only way is to use g_form.showInfoMessage() where you can add HTML tags
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-07-2025 08:10 PM
Hope you are doing good.
Did my reply answer your question?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader