onChange script error: ReferenceError: global is not defined function () { [native code] }

Lokesh Pandey
Tera Contributor
//client script

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
		if ( newValue === '') {
			return;
		}
		
	var ga = new GlideAjax(global.GetCourseDetails_6);
	ga.addParam('sysparam_name', 'getCourse');
	ga.addParam('sysparam_course_code', g_form.getValue('course_code'));
	ga.getXML(callback);
	
	function callback(response)
	{
		var answer = response.responseXML.documentElement.getAttribute("answer");
		
		g_form.setValue('name_of_course',answer);
	}
	
}

//script include

var GetCourseDetails_6 = Class.create();
GetCourseDetails_6.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
getCourse:function(server_side_data) {
		var cc;
		var courseID = this.getParameter('sysparam_course'); // getting value from client side
		gs.info("jhcourse" + courseID);
		var cn = new GlideRecord('x_opepo_courseware_course'); //Gliding to Course table to get Course Code
		cn.addEncodedQuery('sys_id='+courseID); //matching condition table record sys_id with client_side 
		cn.query();
		if (cn.next()) {
			cc=cn.getValue('course_name');
	}
	return cc;
	},

    type: 'GetCourseDetails_6'
});

I'm getting the following error.Please help me fix this.find_real_file.png

3 REPLIES 3

Shane41
ServiceNow Employee
ServiceNow Employee

Hi Lokesh,

When calling the script include it needs to be in quotation marks

var ga = new GlideAjax('global.GetCourseDetails_6');

Hope this helps,

Shane

 

Yes I fixed that.Now,I'm getting "Access to script include blocked error"find_real_file.png

Please help with this

In Script Include, there's a field "Accessible from". Please select it as 'All application scopes' if not done. It should resolve the issue.

 

Hope it helps.