Calling Script Include from client script include is not working for me
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2025 04:34 AM
My Client Script Include :
my client script include :
function include({imports}) {
return shareBulKReports;
function shareBulKReports(query){
var objGA = new GlideAjax("global.shareReportsWithGroups");
objGA.addParam('sysparm_name', "shareReports");
objGA.addParam('sysparm_query',query.toString());
objGA.getXML(validateResponse);
function validateResponse(response){
var result = response.responseXML.documentElement.getAttribute("answer");
}
}
}
var shareReportsWithGroups = Class.create();
shareReportsWithGroups.prototype = Object.extendsObject(AbstractAjaxProcessor, {
shareReports : function(){
var query = this.getParameter("sysparm_query");
gs.info(query,"venkat");
gs.log(query,"venkat");
this.fetchGroups(query);
},
fetchGroups : function(query){
var groupsGr = new GlideRecord("sys_user_group");
groupsGr.addEncodedQuery(query);
groupsGr.query();
var groupSysIds = [];
while(groupsGr.next()){
groupSysIds.push(groupsGr.getUniqueValue());
}
this.shareReportstoGroups(groupSysIds);
},
shareReportstoGroups : function(groups){
gs.info(groups, "venkat");
},
type: 'shareReportsWithGroups'
});
My client script include is working fine, I have logged to check it.
Regards,
Venkat
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2025 04:50 AM
why are you separating the functions?
why not call the single function and do that?
var shareReportsWithGroups = Class.create();
shareReportsWithGroups.prototype = Object.extendsObject(AbstractAjaxProcessor, {
fetchGroups: function(query) {
var query = this.getParameter('sysparm_user_sys_id') || query;
var groupsGr = new GlideRecord("sys_user_group");
groupsGr.addEncodedQuery(query);
groupsGr.query();
var groupSysIds = [];
while (groupsGr.next()) {
groupSysIds.push(groupsGr.getUniqueValue());
}
return groupSysIds.toString();
},
shareReportstoGroups: function(groups) {
gs.info(groups, "venkat");
},
type: 'shareReportsWithGroups'
});
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2025 05:03 AM
I don't think it is calling script include itself firstly, I have kept log statements at the start of the function. I couldn't see any logs.
is there any reason do you think why it is not calling script include?
Regards,
Venkat
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2025 06:15 AM
please share the complete client side code which you are using
both client code and script include are in same scope?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2025 06:47 AM
I have already share in question post. Sharing here it again.
Note: My client script is client script include which generally used in UI Builder Client scripts
my client script include :
function include({imports}) {
return shareBulKReports;
function shareBulKReports(query){
var objGA = new GlideAjax("global.shareReportsWithGroups");
objGA.addParam('sysparm_name', "shareReports");
objGA.addParam('sysparm_query',query.toString());
objGA.getXML(validateResponse);
function validateResponse(response){
var result = response.responseXML.documentElement.getAttribute("answer");
}
}
}
and this is my script include :
var shareReportsWithGroups = Class.create();
shareReportsWithGroups.prototype = Object.extendsObject(AbstractAjaxProcessor, {
shareReports : function(){
var query = this.getParameter("sysparm_query");
gs.info(query,"venkat");
gs.log(query,"venkat");
this.fetchGroups(query);
},
fetchGroups : function(query){
var groupsGr = new GlideRecord("sys_user_group");
groupsGr.addEncodedQuery(query);
groupsGr.query();
var groupSysIds = [];
while(groupsGr.next()){
groupSysIds.push(groupsGr.getUniqueValue());
}
this.shareReportstoGroups(groupSysIds);
},
shareReportstoGroups : function(groups){
gs.info(groups, "venkat");
},
type: 'shareReportsWithGroups'
});
and they are in same application scope.