"Access to Script Include--- blocked from scope---" error

Lokesh Pandey
Tera Contributor
//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'
});



//Client Scripts

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
		if ( newValue === '') {
			return;
		}
		
	var ga = new GlideAjax('x_opepo_servicehub.getCourseDetails');
	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);
	}
	
}

I've created client script and script include in a scoped application named "Servicehub". Also,I've made the script include accessible from All application scopes.On changing the value of the field "Course Code",I'm getting the error :-

Access to Script Include x_opepo_servicehub.getCourseDetails blocked from scope: x_opepo_servicehub

find_real_file.png

Please tell me how to fix this.

9 REPLIES 9

Allen Andreas
Administrator
Administrator

Script Include name is: GetCourseDetails_6

Not just: GetCourseDetails

Please check appropriate spelling/formatting for this line:

var ga = new GlideAjax('x_opepo_servicehub.getCourseDetails');

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

Thank You for the response.I fixed that.However,now I'm getting another error which is:-

 

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

 

Please help with this

Even after fixing that,I'm getting error.find_real_file.png

Hello,

Looks like you have created script include in Global scope , can you check that again ? Also make sure 'Client callable' is check and lastly if issue still persist, create cross scope entry or application caller access entry

https://docs.servicenow.com/bundle/paris-application-development/page/build/applications/reference/c_CrossScopePrivilegeRecord.html

https://docs.servicenow.com/bundle/sandiego-application-development/page/build/applications/task/scope-resource-access.html

Regards

Please hit like and mark my response as correct if that helps
Regards,
Musab