How to make A variable dependent on another variable in service catalog.

Sharath goud1
Giga Contributor

How to make the following variable dependent.

When I selected Desktop then canon dt 101,canon dt 102 should be displayed ,

When i selected Floortop then canon ft 101, canon ft 102 should be displayed.find_real_file.pngfind_real_file.png

 

 

 

6 REPLIES 6

Sravani44
Tera Contributor

Hi Sharath,

 

Other approach is to create two variables with same name as" Printer Model" but with a different backend name and use UI policies to show and hide the variables as required. 

 

For example, create printermodel1,printermodel2(With same name as "Printer Model".printermodel1 contains canon dt 101,canon dt 102 and printermodel2 contains canon ft 101, canon ft 102.

in ui policy condition mention the condition as printer type as desktop and in ui policy action make printermodel1 visible as "true".

Same done can followed for the second one

 

Mark my answer as correct if this helps you in any way

 

Regards,

Sravani

shloke04
Kilo Patron

Hi,

You need to write an On Change Catalog Client Script here on the Variable "Printer Type" and use the code as below:

function onChange(control, oldValue, newValue, isLoading) {
   if (isLoading || newValue == '') {
      return;
   }
	if(newValue == 'Desktop'){ // Replace "Desktop" with the backend choice value of Desktop here
		g_form.clearOptions('Printer Model Variable name Here');
		g_form.addOption('Printer Model Variable Name', 'Chocie 1 Value', 'Chocie 1 Label');
		g_form.addOption('Printer Model Variable Name', 'Chocie 2 Value', 'Chocie 2 Label');
	}else if(newValue == 'Floor Top'){ // Replace "floor Top" with the backend choice value of Desktop here
		g_form.clearOptions('Printer Model Variable name Here');
		g_form.addOption('Printer Model Variable Name', 'Chocie 3 Value', 'Chocie 3 Label');
		g_form.addOption('Printer Model Variable Name', 'Chocie 4 Value', 'Chocie 4 Label');
	}
		

   //Type appropriate comment here, and begin script below
   
}

See screenshot below just replace the variables correctly and you should be good here.

find_real_file.png

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke