Can I get the variable name in a Catalog Client Script?

peterraeves
Mega Guru

In an onchange script on variable 'name_of_var', how can I get the name of that variable inside the script?

For example in this code:

var field = ???

g_form.hideFieldMsg(field, true);

<check something>

g_form.showFieldMsg(field, msg, 'error');

What should I put into the first line to get the name of the variable on which this current CCS is running?

1 ACCEPTED SOLUTION

I understand.



Maybe, some tweak : you "hardcode" the Sys_id of the variable name.



The name could change but the sys_id will remain unchanged.



With a GlideRecord, you can get the variable name from its sys_id.



From Where catalog variable's value are stored ? , it seems that the varaible table is : sc_item_option_mtom


View solution in original post

8 REPLIES 8

lSurya 24
Giga Guru

Hello Peter,



use g_form.getValue("variabloe name");


How does this function get me the variable name?


oops. I understood the question wrong


Try this:


g_form.getLabelOf('variable name'); // see the syntax once



http://wiki.servicenow.com/index.php?title=GlideForm_(g_form)#getLabelOf