Client script didn't working in order guide

zulhiyatiuwi
Tera Expert

Hello... can someone help me? I have a variable set that i configure client script on it. That client script working well in item, but its not working on order guide. I have choose ui type to all. please help.

1 ACCEPTED SOLUTION

zulhiyatiuwi
Tera Expert

i found this link. and when i upgrade my instance, client script its working now. thank you all. 😄

https://hi.service-now.com/kb_view.do?sysparm_article=KB0689536

View solution in original post

10 REPLIES 10

palmen
Tera Guru

Think you need to supply the code you have in the script so we can see what you've done.

This script is for get user information.

find_real_file.png

its working on item, but not in order guide. and also working when i try to create request from system (not /sp). please help. 

Maybe some issue with getReference?

Best practice is to use GlideAjax and that works for me at least. I'll provice some sample code you can modify to your needs

Catalog Client Script (onChange)

function onChange(control, oldValue, newValue, isLoading) {
	if (isLoading || newValue == '') {
		return;
	}
	//AJAX call to lookup Requested for information
	var ga = new GlideAjax('demoUtils'); //Name of Script Include
	ga.addParam('sysparm_name','requestedForValues'); //Function in Script Include
	ga.addParam('sysparm_requestedFor', newValue); //Parameter to pass to function
	ga.getXML(setData);
}

function setData(response) {
	var answer = JSON.parse(response.responseXML.documentElement.getAttribute("answer"));
	if (answer){
		g_form.setValue('demo_user_id', answer.rf_uid);
		g_form.setValue('demo_mobile_phone', answer.rf_mPhone);
	}
}

Script Include

var demoUtils = Class.create();
demoUtils .prototype = Object.extendsObject(AbstractAjaxProcessor, {
	
	requestedForValues: function() {
		var rf = this.getParameter('sysparm_requestedFor');
		//Get the User Record for Requested For
		var gr = new GlideRecord('sys_user');
		gr.get(rf);
		
		//Create an object with parameters
		var obj = {};
		obj.rf_uid = gr.getValue('user_name');
		obj.rf_mPhone = gr.getValue('mobile_phone');
		
		return JSON.stringify(obj);	
	},
	
	
	type: 'demoUtils '
});

the client script is working before in order guide or item. but after doing cloning, i have realized that client script not working in order guide. Did i have doing wrong before it? can i trace what do i do before that script not working anymore? 

I have variable set name "informasi user" in order guide, this variable set have client script for load user information. and in item i add variable set name "non-script informasi user" that didn't include script on it. i thick cascade on order guide, so that information in order guide will include to item. I do it because i need information user for notification. i did'nt know how to take variables value from order guide.