Info Message from description with Line breaks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-04-2017 09:50 PM
I have a requirement, where I need to show the value from an description field with line breaks as an info message..
for eg:
Description:
Type: String
First Line
Second line
third line
So in info message it should retain the same format, like
First Line
Second line
third line
But, actually it is showing like this "First line second line third line"
Thanks in Advance..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-05-2021 11:26 AM
Did you get any alternate solution?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-08-2017 04:50 AM
Insert <BR> instead of \n or <\br> in your message where you need a line break.
Works fine in addErrorMessage.
For your requirement, maybe you should use a variable for your message.
This variable has as input your description, in which your replaced the line breaks by <BR>.
Provide more information on your input : which table/field is it ? If you need more support on how to transform the description into a variable, if this can be done.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-08-2018 05:14 AM
try this:
var controlID = g_form.getControl('other_field_name').id + '_fieldmsg'; //It will give you id of div containing error, warning, info message
g_form.showFieldMsg('other_field_name', g_form.getValue('description_field_name'), 'error'); // here comes the code that shows message
document.getElementById(controlID).style.whiteSpace = 'pre-wrap'; //magic happens here
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-12-2019 07:16 AM
Setting my c.data.description to style="white-space: pre-wrap;" solved my issue perfectly.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-07-2021 04:44 AM
Hi,
I’ve sorted it out this way:
var controlID = g_form.getTableName()+'.' +'u_field_name'+ '_fieldmsg';
g_form.showFieldMsg('u_field_name', msgTrasnlated, 'info'); //I get value previously
document.getElementById(controlID).style.whiteSpace = 'pre-wrap'; //add breaks
Now I want to do the same on Portal form, but "document" does not work on portal.
https://docs.servicenow.com/bundle/paris-servicenow-platform/page/build/service-portal/concept/unsupported_client_scripts.html
Thanks GregM