How to access variables in client script of variable set within the same catalog item?

Sumit Rathod4
Tera Contributor

As many have already posted on the community to try,

g_form.getValue('variables.variable_name');

but I haven't seen any Accepted Solution marking this to be the correct answer.

Even I have tried it but it's not working for me.

I have even tried using just

g_form.getValue('variable_name');

but nothing is working for me.

Is there any solution to how to access variable in client script of variable set of type Multi Row Variable Set (MRVS) belonging to same catalog item on service portal.

I am trying to populate a variable in MRVS using variable set client script depending on a value of variable from record producer.

P.S I have this catalog item in Human Resources : Core

Since I want to access the variable in variable set, the 'Applies to' on the client script has been set to 'A Variable Set' and 'UI Type' is set to 'All'.

Please let me know solution to this issue.

8 REPLIES 8

Kasi Ramanathan
Kilo Guru

Hi Sumit Rathod,

Please find the below link.

Scriptable service catalog variables

Thank you for you reply.

As stated in the document when I tried to use,

current.variables.<variable_name>

upon saving the changes I got an error saying 

The object "current" should not be used in client scripts.

PratyushaBodepu
Mega Guru

Hi Sumit, 

I have tried your scenario in my personal dev and it is working for me when I use getValue and getDisplayValue. 

In this case, VMware Fusion is the Cat item and 'Who is this request for?' and 'when do you need this?' are part of a variable set. I have created a string field called 'test' and populated the value from 'Who is this request for?' onto that string field I created on the Item. I have written the client script on the Catalog Item.

Please find the attached screenshots for reference.

Do cross-check the same with your work and make changes if necessary and try again. Let me know if you are able to fix it.

Thanks, 

B L Pratyusha

Thank you for your reply.

What you have done is the opposite of what I am trying to achieve. You have accessed the variables defined in variable set in client script of catalog item(record producer).

Variables(Client script) <- variables from variable set.

What I want to achieve is access the variables in the client script of variable set.

Variables -> (Client script) variables from variable set.

Sorry I forgot to mention that variables in variable set is of type Multi Row Variable Set. I am trying to populate the value of one of the variable in MRVS depending on the value of Variable from record producer.