how to write field message in new line?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-02-2021 01:52 AM
I want field message to appear like below in a single field message not like double messages.
I have tried \n, <br>,<BR> but no use. Please suggest.
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-02-2021 02:54 AM
Hi,
Can you please provide more information where you are writing this ?
Can you please provide your code?
var msg="Hello World "+"\n"+"How Are you";
this is how we can use "\n" for new line
Please mark as correct/helpful, If you find any help
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-02-2021 02:58 AM
Hi Kajal,
I am writing this on on-change client script - below is the script
var message_text = 'line1' + '\n' + 'line2' + '\n' + 'examples :' + '\n' + 'line3' + '\n' + 'line4';
var controlID = g_form.getControl('variable').id + '_fieldmsg';
g_form.showFieldMsg('variable', message_text, 'info');
document.getElementById(controlID).style.whiteSpace = 'pre-wrap';
this is working fine in native view, but showing error in portal.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-02-2021 03:01 AM
Hi,
DOM manipulation won't work in portal
this line is causing the issue for portal
document.getElementById(controlID).style.whiteSpace = 'pre-wrap';
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-02-2021 03:07 AM
Hi,
document.getElementById(controlID).style.whiteSpace = 'pre-wrap'; document.getElementById() is a DOM manipulation method to get the element from HTML code with the Id will not workin service portal
You can simply use the showFieldMsg() and pass the parameter