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.

Change messages format

ggggasgasgasgas
Kilo Contributor

Hi all,

 

I am working in a custom application. I have to put some messages in 2 tables. Now i have something like that:

find_real_file.png

I want for example change the color of the background and text, take the text in the middle of the row, ect.

How can i format the message? 

Can I have 3 different messages? Or i only can have , Info message and Alert message.

 

Ty so much. 

Best regards

1 ACCEPTED SOLUTION

john_duchock
Kilo Guru

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);
	

however, the only way i know to change the "entire" background color of an info message would be to add a UI Script that sets the background-color property of the class(s)...

Portal, however, can be updated easily using CSS on the page.  I think the class is .alert-danger and you would want to put on the portal TICKET page.  Check out the following link for portal alert stuff...

https://getbootstrap.com/docs/4.0/components/alerts/

 

Hope this helps a little !

View solution in original post

2 REPLIES 2

john_duchock
Kilo Guru

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);
	

however, the only way i know to change the "entire" background color of an info message would be to add a UI Script that sets the background-color property of the class(s)...

Portal, however, can be updated easily using CSS on the page.  I think the class is .alert-danger and you would want to put on the portal TICKET page.  Check out the following link for portal alert stuff...

https://getbootstrap.com/docs/4.0/components/alerts/

 

Hope this helps a little !

GersonCF
Tera Contributor

It has been 4 years since this was posted but it may help other people in the future.. all I did was a client script with Isolated Script off with the following code:

 

g_form.addWarningMessage('Show this with orange background', 'planned_start_is_past');
$("planned_start_is_past").style.background = 'orange';