How to insert multi line info message

Vasu ch1
Tera Contributor

Hi,

I want to display an info message in multi line. How can I do that. I tried inserting "\n" in the string but it is not going to next line. How can do that?

1 ACCEPTED SOLUTION

Allen Andreas
Administrator
Administrator

Hi,

Please refer to the resource for an example: https://servicenowguru.com/scripting/ui-info-error-message-cheat-sheet/

Example:

addInfoMessage(message)Displays an informational message for the current session with a blue information icon and a light-blue background.

Can also include HTML in the message! Note that I've replaced the greater than and less than symbols with brackets in the HTML usage example to get it to display correctly here. You'll need to change the brackets back to standard HTML to get it to work in your instance.
gs.addInfoMessage('Session Info Message Text');

//Info message with HTML formatting
//Create the html contents of the information message
var link = '[a href="incident.do?sys_id=' + current.sys_id + '" class="breadcrumb" ]' + current.number + '[/a]';
var message = 'Incident ' + link + ' has been created. ';
message += 'Thank you for your submission.';

//Add the information message
gs.addInfoMessage(message);

 

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

View solution in original post

4 REPLIES 4

palanikumar
Giga Sage

Can you share the script

Thank you,
Palani

Allen Andreas
Administrator
Administrator

Hi,

Please refer to the resource for an example: https://servicenowguru.com/scripting/ui-info-error-message-cheat-sheet/

Example:

addInfoMessage(message)Displays an informational message for the current session with a blue information icon and a light-blue background.

Can also include HTML in the message! Note that I've replaced the greater than and less than symbols with brackets in the HTML usage example to get it to display correctly here. You'll need to change the brackets back to standard HTML to get it to work in your instance.
gs.addInfoMessage('Session Info Message Text');

//Info message with HTML formatting
//Create the html contents of the information message
var link = '[a href="incident.do?sys_id=' + current.sys_id + '" class="breadcrumb" ]' + current.number + '[/a]';
var message = 'Incident ' + link + ' has been created. ';
message += 'Thank you for your submission.';

//Add the information message
gs.addInfoMessage(message);

 

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

Rajshekhar Pau1
Kilo Guru

Hi,

Can you please share where you are trying to put the info message? It may vary depending on your requirements.

Thanks,
Rajshekhar Paul
Mark Helpful or Correct based on the impact!

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

please try to use <br/>

It worked well for me

(function executeRule(current, previous /*null when async*/) {

	// Add your code here
	var sMsg='line 1<br/>';
	sMsg=sMsg+'line 2<br/>';
	sMsg=sMsg+'line 3';
	gs.addInfoMessage(sMsg); 

})(current, previous);

find_real_file.png

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader