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

yeppie we did it . 

 

Many Thanks Ankur

You are welcome

Regards
Ankur

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

Hi Ankur, 

 

I need your help again on this . I checked that script on Item it was working as i need  but when i checked that on service portal its showing me Javascript error in Catalog client script code for line. 

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

 

Please suggest how to take this error out . 

 

Many Thanks ,

Hi sheetal,

that's correct for service portal it won't work

possibly you should try to get the url parameter and check if that catalog item sys_id is present or not

something like this

var url = top.location.href;
var catalogItemSysId = new URLSearchParams(url).get("sys_id");

Regards
Ankur

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

No Luck Ankur , Please check the final script i wrote :

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

var url = top.location.href;
var catalogItemSysId = new URLSearchParams(url).get("sys_id");

if(catalogItemSysId =='Sys ID of ITEM'){


if (g_form.getValue('var_user_type')=='New User'){
g_form.setVisible('Variable1_name',false);
g_form.setVisible('variable2_name ',false);
}
}