"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

Thank you for the response.Since,I'm in the learning stage now,I've no idea about creating cross scope privilages.Can you brief me the exact steps?

You can move the script include back into scope; now with the correct spelling it should call correctly

Hello,

Sorry, it was assumed at a minimum that your script include was set to be accessible from other scopes. Please check your script include settings.

Regardless of that, it would not have worked if you didn't correct the typo you had.

I hope my reply above was at least Helpful.

Thanks!


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

Aman Kumar S
Kilo Patron

Hey,

You will need to create cross scope privilege for this script include

Refer to below link:

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

 

Feel free to mark correct, If I answered your query.

Will be helpful for future visitors looking for similar questions 🙂

Best Regards
Aman Kumar

Thank you for the response.Since,I'm in the learning stage now,I've no idea about creating cross scope privilages.Can you brief me the exact steps?