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

amlanpal
Kilo Sage

Hi Priyanka,

 

You may make a variable on another variable either based on Catalog Client Script (for Select Box type variables) or via Reference Qualifier (for Reference/List collector type variable). Please refer the below helpful links to achieve the same.

1. https://old.wiki/index.php/Adding_Dependent_Variables

2. https://old.wiki/index.php/Adding_Dependent_Reference_Variables

 

Hope this helps. Please mark the answer Correct/Helpful based on the impact.

Regards,

Amlan

Priyanka Pawar1
Mega Expert

Hello Amlanpal and Chandu Telu,

thank you for all of your reply.

I am not asking how to build this, I already picked up the solution which I can apply in current environment.

I have gone thrue with all the link, then only i have created the above script.

if you can let me know, what is wrong with the catalog client script which i have written.

 

Regards,

Priyanka

i would suggest here to add some alert in your catalog client script to validate the value of newValue . kindly share the alert details. make sure the condition is working or not

 

example:

 

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

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

      return;

   }

alert('New Value'+ newValue);

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

alert('if condition is working');

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

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

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

  }  

}