Using g_form.flash on a service catalog form

treycarroll
Giga Guru

When I try to use

 

g_form.flash('sc_cat_item.ci_name','#FF0000',-4);

 

from a catalog client script, I get the following error

 

flash error.png

 

The documentation for g_form flash states the the widget name should be in the form <table name>.<field name>

 

I have tried:

g_form.flash('sc_cat_item.variables.ci_name','#FF0000',-4);

 

g_form.flash('variables.ci_name','#FF0000',-4);

g_form.flash('sc_cat_item.ci_name','#FF0000',-4);

g_form.flash('ci_name','#FF0000',-4);

 

Is there no way to make a field flash on a service catalog form?

1 ACCEPTED SOLUTION

Matthew Swarts
Tera Guru

Hi Trey,



I was able to apply g_form.flash to service catalog variables by first inspecting the element I want using Firebug in Firefox and locating the label_IO sys_id.   then use that in place of the variable name in the script.



For an onLoad example:



function onLoad() {


        g_form.flash('label_IO:33586fd4ad054100872edb6647c09400',"#CC0000", -2);


}



You just need the correct label_IO and associated sys_id which you can copy out of Firebug and you should be good.


View solution in original post

6 REPLIES 6

Matthew Swarts
Tera Guru

Hi Trey,



I was able to apply g_form.flash to service catalog variables by first inspecting the element I want using Firebug in Firefox and locating the label_IO sys_id.   then use that in place of the variable name in the script.



For an onLoad example:



function onLoad() {


        g_form.flash('label_IO:33586fd4ad054100872edb6647c09400',"#CC0000", -2);


}



You just need the correct label_IO and associated sys_id which you can copy out of Firebug and you should be good.


Thank you for the quick answer, Matthew.   I had already tried.



g_form.flash('IO:<var sys id>','#FF0000',-4);



But I did not know to pre-pend "label_".



Thanks for sharing this tip!


Jared Healy2
Kilo Expert

I realize this is a little bit older post but I think others will find it. One additional recommendation to avoid hard coding any sys_ids is to utilize the getControl() function.



var myElement = g_form.getControl('variable_name');


g_form.flash("label_" + myElement.id, "#FFFACD", 0);



This way you're relying on a ServiceNow function to get the correct element id.


sgc
Giga Contributor

We upgraded to Fuji and came to know this type of code is working fine in Eureka but not in Fuji, Can you anyone give me an idea how to make it work in Fuji



Thanks,


Sri.