How do I refer to variables in variable sets in a client script?

gtke
Tera Contributor

I have a variable which is the only variable in a variable set. I am trying to modify this variable using a client script (g_form.setValue()) but it isn't working. I have another variable which is not in a variable set and that one can be set through g_form.setValue() in a client script. Currently I am referring to the variable in the set like this: g_form.setValue('<variable>','<value>','<display>') but I have also tried g_form.setValue('<variable set>.<variable>','<value>','<display>') and g_form.setValue('variables.<variable>','<value>','<display>') but none of these works. What is the proper syntax for this reference?

13 REPLIES 13

justin_drysdale
Mega Guru

It shouldn't matter if the variable is part of a set or if it is stand alone.   g_form.setValue() will work against either.


The proper way is:


g_form.setValue('variable','value'); You can specifiy a third paramater (display value) however you probably don't need to.   Try it without.



What is the variable type that is part of a set, that is not working for you?


The variable is a select box, and I am feeding g_form.setValue() valid values. Does it matter if the client script is running against the catalog item or the variable set? I have tried both but I've probably missed some combination of things to get it just right.


Paste your script here


gtke
Tera Contributor

function onSubmit() {


    //Type appropriate comment here, and begin script below


      alert('SCRIPT EXECUTING');


    g_form.setValue('action.action', 'remove_access', 'remove access');


}



I have since changed the variable type to single line text but it still isn't working. The script applies to the catalog item and it is executing (according to the alert) when expected. The value of action is still not being assigned. I have tried both action and action.action (action is the name of both the variable set and the variable)