cross scoped application to allow script include to client script interaction
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-22-2022 08:19 PM
Hi,
I have created a cross scoped application two custom tables to establish an interaction between script include to client script.
This is the script include:
var getCourseDetails5 = Class.create();
getCourseDetails5.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getCourse:function() {
var cc;
var courseID = this.getParameter('sysparam_course'); // getting value from client side
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: 'getCourseDetails5'
});
The is the client script:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if ( newValue === '') {
return;
}
// var nv = 'newValue';
// alert("jhcourse" + nv);
g_form.getValue("course_code");
var ga = new GlideAjax('x_opepo_servicehub.getCourseDetails5'); //Contains Script Include Name
ga.addParam('sysparm_name','getCourse'); //This contains the function name
ga.addParam('sysparm_course', 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);
}
}
When I select the course code, the "course_name" does not appear. Is there a missing script that will make the course name appear when a course code is selected?
Kind regards
- Labels:
-
Script Debugger
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-22-2022 08:28 PM
Hi,
script include and client script both are in same scope?
Both are in different scope? if yes then is script include set to accessible from all application scopes
What debugging have you performed till now?
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-22-2022 08:44 PM
Hi Ankur,
Yes, script include and client script both are in same scope.
Have only done some basic debugging like gs.info and looking at logs
Kind regards
Jason
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-22-2022 08:56 PM
Hi,
is that a custom scope or global scope?
if custom scope then there is syntax issue; check below
Is script include client callable?
var getCourseDetails5 = Class.create();
getCourseDetails5.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
getCourse:function() {
var cc;
var courseID = this.getParameter('sysparam_course'); // getting value from client side
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: 'getCourseDetails5'
});
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader