How to make dependent Variable on catalog item

Priyanka Pawar1
Mega Expert

Hello All,

I am creating dependent Variables on catalog item via client script.

Server certificate variable will be dependent on Location Variable.

Now the catalog where I am defining it is contains ordered guide, Location filed is set on one page and the dependent field is set on another page.

I have written below on change client script to achieve this but not working:-

function onChange(control, oldValue, newValue, isLoading) {

   if (isLoading || newValue == '') { 

      return;

   }

  if(newValue=="TM-01"){

                  g_form.removeOption('ServerCertificate1', "rsp-1000.oberthur.net");

                  g_form.removeOption('ServerCertificate2', "rsp-1000.oberthur.net");

                 g_form.removeOption('ServerCertificate3', "rsp-1000.oberthur.net");

  }  

}

1 ACCEPTED SOLUTION

Priyanka Pawar1
Mega Expert

Hello Harshvardhan,

Thank you for the help.

I solved this issue, by making my script onLoad not on change.

I just had a thought that my catalog is using order guide, and that location variable is not on the same page where i want to remove the option.

so on change script is defiantly not gonna work.

 

Here is the catalog client script for future reference, from which I achieved the desired result:-

 

function onLoad() {

if(g_form.getValue('Location') == "TM-01"){
g_form.removeOption("ServerCertificate1", "rsp-0000.oberthur.net");
g_form.removeOption("ServerCertificate2", "rsp-0000.oberthur.net");
g_form.removeOption("ServerCertificate3", "rsp-0000.oberthur.net");
}

}

 

Regards,

Priyanka

View solution in original post

7 REPLIES 7

Priyanka Pawar1
Mega Expert

Hello Harshvardhan,

Thank you for the help.

I solved this issue, by making my script onLoad not on change.

I just had a thought that my catalog is using order guide, and that location variable is not on the same page where i want to remove the option.

so on change script is defiantly not gonna work.

 

Here is the catalog client script for future reference, from which I achieved the desired result:-

 

function onLoad() {

if(g_form.getValue('Location') == "TM-01"){
g_form.removeOption("ServerCertificate1", "rsp-0000.oberthur.net");
g_form.removeOption("ServerCertificate2", "rsp-0000.oberthur.net");
g_form.removeOption("ServerCertificate3", "rsp-0000.oberthur.net");
}

}

 

Regards,

Priyanka

Snehal2
Kilo Guru

Here is the blog post I have written that can help you. Dependent catalog variables can be created in two ways. 

https://community.servicenow.com/community?id=community_article&sys_id=ed94c724db75c410feb1a851ca961...

Hit Like if this helps you!

Regards,

Snehal

Kailash Bhange
Kilo Sage
Kilo Sage

Hi All,

Please take a look at Article below:

1. dependent on single table
2. dependent on two tables using referene

[SOLVED]: - Dependent variable on Catalog item using Lookup Select Box
https://community.servicenow.com/community?id=community_article&sys_id=1ce7dceedb5914101cd8a345ca961952

If my answer solved your issue, please mark my answer as Correct & 👍Helpful based on the Impact.

Thank you!
Regards,
Kailash.