how to show a field in a variable set for a particular catalog item

Bharath kumar6
Tera Expert

I have field in a variable set and this variable set is included in 130 catalog items.

And I want this particular field to be hidden for 2 catalog items and show in all 128 catalog items.

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@Bharath kumar 

2 Approaches

1) you can use 1 onLoad catalog client script for your variable set

Applies to Variable set - True

Then check the sysId of the current catalog item and if it's one of those 2 then hide it

function onLoad(){
	
	var sysId = g_form.getUniqueValue();
	
	// give the 2 catalog item sysIds here
	if(sysId == 'catItemSysId1' || sysId == 'catItemSysId2'){
		g_form.setDisplay('variableName', false);
	}
	
}

OR

2) Create individual Catalog UI policy on those 2 catalog items and hide that variable

Regards
Ankur

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

View solution in original post

4 REPLIES 4

Mohith Devatte
Tera Sage
Tera Sage

Hello ,  

you can write UI policy at catalog item level but not inside a variable set

open your catalog item and create a catalog UI policy to hide that particular field .Please do it for both the catalog items

Please accept this solution  if it helps you 

Thanks

Harish KM
Kilo Patron
Kilo Patron

Hi you can use a UI Policy and select applies to catalog item Refer attached screenshot

Regards
Harish

Ankur Bawiskar
Tera Patron
Tera Patron

@Bharath kumar 

2 Approaches

1) you can use 1 onLoad catalog client script for your variable set

Applies to Variable set - True

Then check the sysId of the current catalog item and if it's one of those 2 then hide it

function onLoad(){
	
	var sysId = g_form.getUniqueValue();
	
	// give the 2 catalog item sysIds here
	if(sysId == 'catItemSysId1' || sysId == 'catItemSysId2'){
		g_form.setDisplay('variableName', false);
	}
	
}

OR

2) Create individual Catalog UI policy on those 2 catalog items and hide that variable

Regards
Ankur

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

Hi @Ankur Bawiskar When I tried to use g_form.getUniqueValue() in onLoad client script scoped application it is returning me sysid of variable set but not record producer. Is there any work around?

TIA