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

imrane
Kilo Expert

Hi,



I guess from this it is not possible.  



It seems you must know the variable name to use it.



Just for the record, why do you want to dynamically get the "current" variable name on onchange script ?


It's a habit. I try to do as less hardcoding as possible. You never know if the name of the variable changes due to some reason (or if I make a typo, which could happen).


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


Thanks Imrane.