Unable to hide Variable set variables for one catalog item.

shweta5
Giga Expert

Hi Experts,

I am unable to run my catalog UI policy on variables of Variable set  over Catalog UI Policy on Variable Set . 

I tried Catalog Client script on my catalog item to hide the variable set variables but no luck .

I am using one variable set which is being used by more than 10 catalog items . On this variable set , two catalog UI policies are running which is taking precedence over catalog item UI policy . 

Please help me out to achieve this .

 

Thanks in Advance

 

24 REPLIES 24

Hi Ankur,

Thanks for your prompt response . Yes I need the same for now i am trying for only one catalog item.

 

Thanks

Hi Sheetal,

if you are currently looking for single catalog item then do this

1) Applies to - variable set

2) Type - onchange

3) Variable set - give your variable set name here

4) variable - var_user_type

5) UI Type - ALL

6) Script:

Note: Ensure you give your catalog item sys_id in the script below so that it runs only 1 catalog item now

function onChange(control, oldValue, newValue, isLoading) {
	if (isLoading || newValue == '') {
		return;
	}

	var catItemSysId = g_form.getParameter("sysparm_id");

	if(catItemSysId == 'yourCatalogItemSysIdHere'){

		if (g_form.getValue('var_user_type')=='Guest'){
			g_form.setVisible('variable_name_1',false);
			g_form.setVisible('variable_name_2',false);
		}	
	}

	//Type appropriate comment here, and begin script below

}

find_real_file.png

Regards
Ankur

 

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi Ankur,

 

Thanks again . I tried this but its not working for me .

 

It might be due to one UI policy that is already  running on Variable set.

I have unchecked this property also but no Luck 

 

find_real_file.png

 

Hi Sheetal,

Just to make sure it works just disable any other Catalog UI Policy or catalog client script on that variable set

what happens when the value is changed? did you try adding alert and check?

Note: Also check correct catalog item sys_id and valid value of var_user_type, valid variables to hide

function onChange(control, oldValue, newValue, isLoading) {
	if (isLoading || newValue == '') {
		return;
	}

	var catItemSysId = g_form.getParameter("sysparm_id");

	if(catItemSysId == 'yourCatalogItemSysIdHere'){
          alert('Inside my catalog item sys id');
		if (g_form.getValue('var_user_type')=='Guest'){
                        alert('Inside hiding the variables');
			g_form.setVisible('variable_name_1',false);
			g_form.setVisible('variable_name_2',false);
		}	
	}

	//Type appropriate comment here, and begin script below

}

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader