We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. Read more

Line breaks in showFieldMsg()?

Joey Wan Kenobi
Tera Guru

Hello,

Does anyone know of a way to insert line breaks in a field message within the showFieldMsg() method?

Tongue Twister not intended.

Thanks

18 REPLIES 18

Harish Murikina
Tera Guru

The below trick worked for me.



EX:



var msg = "Hellow World*ABC*XYZ";


var spli = msg.split('*');


var len = spli.length;



for(var i=0; len>i; i++)


{


g_form.showFieldMsg('impact', spli[i], 'error');


}


errormsg.JPG






Regards,


Harish.


This is great. It adds the later messages on top of earlier ones though, so only thing I changed was to loop in the other direction.


Vladi
Tera Contributor

Use "\n" instead, for example:


g_form.setValue('comments', oldComments +"\n" + " Owner Group " + group + " already exists",'info');


Zod
Giga Guru

I have the same question ... any solution found?


The \n"   did not work for me ...


Hello,


Yes the solution that Harish suggested on 5th January 2015 works well.


I can't mark Harish's answer as correct - I think maybe the original poster has to do this.



Jamie.