How to access a variable inside a variable set using Client script ?

DD18
Kilo Explorer

I am trying to access a variable of a variable set using an On_change client script but not sure about the steps.

Var set name : on_behalf_of

Var name : caller_id - which refers to a table user_info

Tried using - var clrID = g_form.getValue('variables.caller_id'); but I could see an empty alert box when I try to print clrID . Attached the same for reference. Any idea would be useful.

Thanks in advance.

7 REPLIES 7

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

you should directly use the variable name;

var clrID = g_form.getValue('caller_id');

alert(clrID);

Mark Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Ankur is correct. You should be able to access this variable directly.

Hi,

I can use the code mentioned in conjunction of a variable & catalog item.

The behavior does not seem to be present when interacting with a multi-row variable set.

I am trying to create a MRVS that lets a user select from their own assets only.

Any ideas?

 

-Lon

Dear Ankur,

 

I am trying to use clear value on two variables in variable set, one is a select box and one is date time. And these API's (g_form.clearValue('select_Box')) is not working on these two types of variables when these variables are in a variable set. It works when it is present in catalogue item but not when used inside a variable set. Reference type variable is working fine while inside a variable set. Can you please help me with it.