showFieldMsg - Rather than use OoB Font color or Background, can I use something different?

Jimmy45
Giga Guru

Hi Community! 

I have created a catalog client script for showFieldMsg using 'warning' and it currently shows up just fine with the orange background color and the text is black.  However, our client wants this to appear in a black background with white text.  How can I achieve this?  Here is the current code:

function onChange(control, oldValue, newValue, isLoading) {
   if (isLoading || newValue == '') {
      return;
   }

 var choice = g_form.getValue('app_media');

if (choice == 'Yes'){
       g_form.showFieldMsg('app_media', "This is a test message", 'warning');

	}
		

}

 

How can I achieve the below result?

find_real_file.png

1 ACCEPTED SOLUTION

Seshpri M
Kilo Guru

Hi,

 

You cannot do this with a showFieldMsg, as it only allow you to show a msg or an error.. Alternatively,

 

What I think you can do is:

 

Add Html variables and make their visibility as tru or false through ui policy or client script based on the other variable the user is clicking.

 

 

For info on catalog variable types, pls refer here:

 

https://docs.servicenow.com/bundle/rome-servicenow-platform/page/product/service-catalog-management/reference/r_VariableTypes.html

View solution in original post

4 REPLIES 4

Seshpri M
Kilo Guru

Hi,

 

You cannot do this with a showFieldMsg, as it only allow you to show a msg or an error.. Alternatively,

 

What I think you can do is:

 

Add Html variables and make their visibility as tru or false through ui policy or client script based on the other variable the user is clicking.

 

 

For info on catalog variable types, pls refer here:

 

https://docs.servicenow.com/bundle/rome-servicenow-platform/page/product/service-catalog-management/reference/r_VariableTypes.html

Sai Kumar B
Mega Sage
Mega Sage

@Jimmy45 Not sure how to do with showFieldMsg()

function onChange(control, oldValue, newValue, isLoading) {
   if (isLoading || newValue == '') {
      return;
   }

 var choice = g_form.getValue('app_media');
 var message = '<p style="color:white;background-color:black;"> Test Message </p>';
if (choice == 'Yes'){
       gs.addInfoMessage(message);
	}
		

}

Thanks Sai.  I realize you can do this with an addInfoMessage, but the client wants it to appear just below the variable on the form instead of at the top of the screen.  Great idea though!  I may have to just go with @Seshpri M advice if this cannot be done.

yeah you can create widget/custom variable and make it visible using UI policy.