Need to hide variable set on catalog item from a order guide

Aswin Chandras1
Tera Contributor

Hi All,

 

I have an order guide Replace Request where it contains Laptop as catalog item and it is called in multiple order guides.

My requirement is if my order guide is replace request then I need to hide the financial variable set in the laptop catalog item which is called in the order guide. My variable set is in catalog item not on order guide.

For other order guide, the variable set should be displayed. My variable set is in catalog item not on order guide.

5 REPLIES 5

Tim Deniston
Mega Sage
Mega Sage

Whenever I need to determine if the catalog item is currently being used in an order guide, I use this in a catalog client script (associated to the catalog item or variable set): 

var isOrderGuide = g_service_catalog.isOrderGuide();

This is only available in service portals, so hopefully you're using a service portal to access your catalog and order guide.

 

If users could be using the catalog (and thereby the order guide) in Core UI/frameset, you will need to use some jQuery to make accommodations. Check out the "Run code on order guides in and out of the portal" located here: https://jace.pro/post/2017-09-25-useful-client-scripts/ 

To add to this, you'll need to check the URL to see which order guide is in use. This goes against some recommended practices, so use it at your own risk. 

 

Much of this has probably been borrowed from different sources. I can't cite them off hand. 

 

function onLoad() {
	var isOrderGuide = g_service_catalog.isOrderGuide();
	var windowPath = location.search;
	var windowParams = windowPath.split('?')[1];
	var params = windowParams.split('&');
	var sys_id = '';
	for (var i = 0; i < params.length; i++) {
		if (params[i].toString().indexOf('sys_id') == 0) {
			sys_id = params[i].split('=')[1];
			break;
		}
	}
	var isReplaceRequest = (sys_id == 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'); //replace with the sys_id of the Replace Request order guide. Yes, I know... don't put sys_ids in code. 
	
	if (isOrderGuide && isReplaceRequest) {
		g_form.setDisplay('first_variable_name', false);
		g_form.setDisplay('second_variable_name', false);
        // ... repeat until all variables in the set are not visible
        // Service Portal does not seem to hide variable sets using "g_form.setDisplay('variable_set_name', false);"
        // though Core UI/frameset does. If the  variables in your variable set are in a container, you might be 
        // able to use "g_form.setDisplay('container_variable_name', false);" but I have not tested that.
	}
}

 

Hi @Tim Deniston 

I tried but am getting the info message as below:
Info Message

This catalog client script is not VA supported due to the presence of the following variables in the script: window, $




It sounds like you're trying to submit this via virtual agent or conversation mode. Is that right? I don't think this would work in that mode, nor would order guides. 

 

Please ensure the 'UI Type' value is "All" and the 'Isolate Script' is true/checked. The 'UI Type' value allows the script to run in Core UI, Service Portal, or both. The 'Isolate Script' checkbox allows things like jQuery, DOM manipulation, etc. Here's the message that appears at the top related to Isolate Script: 

New client-scripts are run in strict mode, with direct DOM access disabled. Access to jQuery, prototype and the window object are likewise disabled. To disable this on a per-script basis, configure this form and add the "Isolate script" field. To disable this feature for all new globally-scoped client-side scripts set the system property "glide.script.block.client.globals" to false.