Pass Order Guide Variables to Catalog Task Without Showing in in each Catalog item in Order Guide

jwagner
Tera Contributor

I've created a new hire order guide with the several variables I'd like to share across all included catalog items. 

Common info I'd like to have on all catalog tasks: Supervisor/First Name/Last Name/Shift/Title/Department/EmployeeID 

Catalog items: Build Computer/ Setup Phone/ Setup Email/ Create Access

There is no need for the user to see all those fields listed on each catalog item within the order guide, but I want to pass the variables to help the fulfiller.

 

 

 

 

 

 

and the following set of informaktion I'd like to carry over to each catalog item, but 

1 ACCEPTED SOLUTION

Brent Sutton
Mega Sage

Hi Ya,

Create the common variables in a variable set and include the variable set on the order guide and all catalog items that can be selected in the order guide. In the variable set you need to create an onload client script with UI Type set to "All" so it runs on both platform and Service Portal. Should look something like this:

function onLoad() {
	
	if (window === null) {
		// check if we are in an order guide using the g_service_catalog api for Service Portal and Mobile
		var isOrderGuide = g_service_catalog.isOrderGuide();
		
		if (isOrderGuide) {
			//call function to hide the fields on the catalog items if this is an order guide.
			hideVariables();
		}
	}
	else {
		var item = gel("current_item");
		var guide = gel("sysparm_guide");

		if (item != null && guide != null && item.value != guide.value) {
			hideVariables();
		}
	}
	
	function hideVariables(){
		g_form.setDisplay('your_var1',false);
		g_form.setMandatory('your_var2',false);
		g_form.setDisplay('your_var2',false);
	}
}

On the order guide tick "Cascade variables" option which will copy the value of the data captured in the order guide down to the Service Catalogue items

find_real_file.png

That should now hide the variables, when displayed within an order guide. More information can be found about cascading variables at the following link - Cascade an order guide variable

Let me know how you get along.

Brent

P.S. If my suggestion helped then please mark as helpful and/or correct so other community members can benefit from this information.

View solution in original post

12 REPLIES 12

Brent Sutton
Mega Sage

Hi Ya,

Create the common variables in a variable set and include the variable set on the order guide and all catalog items that can be selected in the order guide. In the variable set you need to create an onload client script with UI Type set to "All" so it runs on both platform and Service Portal. Should look something like this:

function onLoad() {
	
	if (window === null) {
		// check if we are in an order guide using the g_service_catalog api for Service Portal and Mobile
		var isOrderGuide = g_service_catalog.isOrderGuide();
		
		if (isOrderGuide) {
			//call function to hide the fields on the catalog items if this is an order guide.
			hideVariables();
		}
	}
	else {
		var item = gel("current_item");
		var guide = gel("sysparm_guide");

		if (item != null && guide != null && item.value != guide.value) {
			hideVariables();
		}
	}
	
	function hideVariables(){
		g_form.setDisplay('your_var1',false);
		g_form.setMandatory('your_var2',false);
		g_form.setDisplay('your_var2',false);
	}
}

On the order guide tick "Cascade variables" option which will copy the value of the data captured in the order guide down to the Service Catalogue items

find_real_file.png

That should now hide the variables, when displayed within an order guide. More information can be found about cascading variables at the following link - Cascade an order guide variable

Let me know how you get along.

Brent

P.S. If my suggestion helped then please mark as helpful and/or correct so other community members can benefit from this information.

Hi Jeremy, Did you include the onLoad client script on your variable set? You need to amend the variable names in the hideVariables function at the bottom of the script. This should be the names of the variables you are needing to hide. Brent

Hi Bent,

This thread helped me to achieve the same scenario. But I am facing one issue please help me out.

The catalog items which are used in the order guide can also be used individually to submit a request in that case the variables are not getting hidden. The above code is working fine if the catalog item is assiciated to an order guide but  if it is submitted individually it is not

Hi Ya,

Please take a look at my solution provided at the following link.

Hiding Order Guide cascading variables on Desktop - DOM issues

I think this information will solve your issue.

Let me know if this worked for you.

Brent

P.S. If my suggestion helped then please mark as helpful and/or correct so other community members can benefit from this information.