How to change background color for info message

aarya1
Giga Contributor

Hi

How do i change the background color for info message (Normally we get info message in blue color but in my case i need to get it in different color).

Could you please suggest for my approach

Regards

Aarya

1 ACCEPTED SOLUTION

Saurav11
Kilo Patron
Kilo Patron

Hello Aarya,

 

There are additional message types that you can use:

g_form.addWarningMessage = yellow

g_form.addErrorMessage = red

g_form.addInfoMessage = blue

you can change the font color using the following script:

var message1 = 'TEST';
var message2 = message1.fontcolor("red");
g_form.addInfoMessage(message2);

You can also use text background high-lighting such as:

var message = '<b><p style="color:black;background-color:orange;">';
message+='TEST';
g_form.addInfoMessage(message);
	

or

var message = '<div style="background-color:blue;color:white">Assignment group changed.<br/>';
g_form.addInfoMessage(message);
	

 

Hope this helps. Please mark the answer as correct/helpful based on impact.

 

View solution in original post

8 REPLIES 8

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

you can add html tag for that

Regards
Ankur

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

Hi,

Example: you can add color to the text but not the other one

Display business rule for this

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

	// Add your code here
	var str1 = '<p style="background-color:tomato;">This is my message</p>';
	gs.addInfoMessage(str1);

})(current, previous);

find_real_file.png

Regards
Ankur

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

To keep the text of your info message nicely in the one line you can change it slightly:

var str1 = '<p div style="background-color:tomato; display: inline-block;">This is my message</p>';

Anil Lande
Kilo Patron

Hi,

There are no ways to change color of info Messages, you can see below link listed possible ways to use messages, alerts etc in ServiceNow.

https://docs.servicenow.com/bundle/rome-application-development/page/script/general-scripting/refere...

 

If you want to show some messages on form for fields then we can use macros or annotations to show custom UI elements.

 

Thanks,
Anil Lande

Please appreciate the efforts of community contributors by marking appropriate response as correct answer and helpful, this may help other community users to follow correct solution in future.
Thanks
Anil Lande