Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

Snehal2
Kilo Guru

Hi All,

Unfortunately, catalog variables do not have a dependency like a field we have on the forms.

find_real_file.png

The dependent variables can be created in the service catalog in two ways:

A. Using Client Script: Onchange of Category field write following script

function onChange(control, oldValue, newValue, isLoading) {
	if (isLoading || newValue == '')
	{
		g_form.clearOptions('subcategory');
		g_form.addOption('subcategory', '', '-- None --');
		return;
	}
	if(newValue =='Category 1')
		{
		g_form.clearOptions('subcategory');
		g_form.addOption('subcategory', '', '-- None --');
		g_form.addOption('subcategory','Subcategory11','Subcategory11');
		g_form.addOption('subcategory','Subcategory12','Subcategory12');
		g_form.addOption('subcategory','Subcategory13','Subcategory13');
	}
	else if(newValue =='Category 2')
	{
		g_form.clearOptions('subcategory');
		//g_form.addOption('subcategory', '', '-- None --');
		g_form.addOption('subcategory','Subcategory21','Subcategory21');
		g_form.addOption('subcategory','Subcategory22','Subcategory22');
		g_form.addOption('subcategory','Subcategory23','Subcategory23');
	}
	else if(newValue =='Category 3')
	{
		g_form.clearOptions('subcategory');
		g_form.addOption('subcategory', '', '-- None --');
		g_form.addOption('subcategory','Subcategory31','Subcategory31');
		g_form.addOption('subcategory','Subcategory32','Subcategory32');
		g_form.addOption('subcategory','Subcategory33','Subcategory33');
	}	
}

B. By Creating the table:

The client script cannot be used when we have a large number of categories and subcategories. So in such a case, we have to follow the 2nd way i.e create a table. Following are the steps you need to follow:

find_real_file.png

Now consider bank name as category and Bank choice as subcategory.

STEPS:

1. Create a custom table that contains the values of the category and subcategory. This will act as a dependency table.

find_real_file.png

2. Create Category - type of variable->Select box , and add all the required choices

find_real_file.png

3. Create Subcategory - type of variable->Lookup select box

find_real_file.pngfind_real_file.png4. Add Reference Qualifier and Variable attributes as shown in the above image.

 

Hit like if this post helps you.

 

Regards,

Snehal Madakatti

Comments
Dev M
Tera Contributor

The Script works Perfect. Thank You

Version history
Last update:
‎12-15-2019 06:24 AM
Updated by: