How do I make Catalog client script run only on Catalog item form and not when in Order guide ?

Supreeth R
Kilo Contributor

Hello,

There is a catalog client script written on a variable set that I've created on. And, have used the variable set in the catalog item as well as in the order guide. 

Now the actual requirement is, I want the catalog client script to run only on the standalone catalog item form having the variable set and not on the order guide form (even if the order guide has that particular item in it) .

Could someone help me achieve this, please ? Thanks in Advance!!

 

1 ACCEPTED SOLUTION

Willem
Giga Sage
Giga Sage

Can you try this for native UI:

$("sysparm_guide").value

 

for example:

if($("sysparm_guide").value){
		return;
	}

 

based on:

https://community.servicenow.com/community?id=community_question&sys_id=a3555ddddb36e3409540e15b8a96...

 

Or try:

g_request.getParameter('sysparm_guide')

 

Example:

if(g_request.getParameter('sysparm_guide')){
		return;
	}

 

Based on:

https://community.servicenow.com/community?id=community_question&sys_id=7c350f6ddbd8dbc01dcaf3231f96...

View solution in original post

6 REPLIES 6

Willem
Giga Sage
Giga Sage

Can you try this for native UI:

$("sysparm_guide").value

 

for example:

if($("sysparm_guide").value){
		return;
	}

 

based on:

https://community.servicenow.com/community?id=community_question&sys_id=a3555ddddb36e3409540e15b8a96...

 

Or try:

g_request.getParameter('sysparm_guide')

 

Example:

if(g_request.getParameter('sysparm_guide')){
		return;
	}

 

Based on:

https://community.servicenow.com/community?id=community_question&sys_id=7c350f6ddbd8dbc01dcaf3231f96...

Hello @Willem,

I tried both of the above scripts given by you (in native UI) but it throws up an error message right under the Primary Contact field in the catalog item form as shown below. However, the same works fine in Order guide.

Note - I've unchecked the "Isolate" field because of the usage of '$' in client script.

 

Error message on catalog item form -

find_real_file.png

 

 

Client Script - 

 

function onChange(control, oldValue, newValue, isLoading) {


var orderGuide = $("sysparm_guide").value;
if (orderGuide == 'fb02172bdb0c6010e2aa874239961975')
return;


Info();

function Info() {
var ga = new GlideAjax('Caller_Information');
ga.addParam('sysparm_name', 'Caller_Details');
ga.addParam('sysparm_caller', g_form.getValue('primary_contact'));
ga.getXML(UserInfo);
//var customer = g_form.getReference('u_customer', setLocation);
}

function UserInfo(response) {
var answer1 = response.responseXML.documentElement.getAttribute("answer");
var answer2 = answer1.split(',');
if (answer1 != '') {
g_form.setValue('department', answer2[0]);
g_form.setValue('phone_number', answer2[1]);
g_form.setValue('email_id', answer2[2]);
}
}
}

 

Any thoughts in here would be of great help. Thank you!