Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Info Message Client Script

Russell Park
Mega Guru

I am trying to add a blue bar info message under a field with a client script.  I want the info message to be several lines.  How can I do a line break on the info message to have the message show on multiple lines?  I want it to look like the below but I have tried a few different options and it just puts in on the same line.

5 - Exceeds

4 - Meets

 

function onLoad() {
    g_form.showFieldMsg("u_review", ("5 - Exceeds" +  + "4 - Meets"));
    callback(saveAndClose);

}

find_real_file.png

1 ACCEPTED SOLUTION

I just put an alert to confirm.

You can comment out the alert line in your code.

find_real_file.png


Please mark my response as correct and helpful if it helped solved your question.
-Thanks

View solution in original post

10 REPLIES 10

chidanandadhath
Kilo Guru

try this

function onLoad()

{ g_form.showFieldMsg("u_review", ("5 - Exceeds" +"\n" + "4 - Meets")); callback(saveAndClose); }

Prateek kumar
Mega Sage
function onLoad() 
{ 
g_form.showFieldMsg("u_review", ("5 - Exceeds" +'\n'+ "4 - Meets")); 
callback(saveAndClose);
 }

Please mark my response as correct and helpful if it helped solved your question.
-Thanks

Prateek,

  This is what I get when I use that code.  Is there a different option I can use to get my needed results?

 

find_real_file.png

Try this out:

Make sure you uncheck Isolate script field on the record.

find_real_file.png

function onLoad() {
var str = "5 - Exceeds" +"\n"+ "4 - Meets";
alert(str);
var controlID = g_form.getControl('u_review').id + '_fieldmsg'; 
g_form.showFieldMsg('u_review', str); 
document.getElementById(controlID).style.whiteSpace = 'pre-wrap'; 
callback(saveAndClose);

}

 


Please mark my response as correct and helpful if it helped solved your question.
-Thanks