Script Include no running
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-19-2025 05:12 AM
I have a Client Script and a Script Include, but I'm having an issue because the Script Include seems to only execute when I am an admin. If I impersonate another user, the logs I have in the Script Include do not appear. Does anyone know why I might be experiencing this issue? Thanks in advance!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-19-2025 05:24 AM
is that user an snc_external user?
if yes then add this function in your script include
isPublic: function() {
return true;
},
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
‎02-19-2025 05:27 AM
This is the script, i think that is external user.
var CheckUserDepartment = Class.create();
CheckUserDepartment.prototype = Object.extendsObject(AbstractAjaxProcessor, {
isUserInTargetDepartment: function() {
var userId = this.getParameter('sysparm_user_id');
gs.info('Id Usuario: ' + userId );
var userGR = new GlideRecord('sys_user');
if (userGR.get(userId)) {
var deptSysId = userGR.getValue('department');
gs.info('Departamento: ' + deptSysId);
if (deptSysId) {
var deptGR = new GlideRecord('cmn_department');
if (deptGR.get(deptSysId)) {
var structure = deptGR.getValue('u_complete_structure');
gs.info('Estructura: ' + structure);
if (structure.includes('9731')) {
gs.info('Devuelve True');
return 'true';
}
}
}
}
gs.info('Devuelve False');
return 'false';
}
});
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-19-2025 05:43 AM
then I already informed what needs to be done. simply add that function
var CheckUserDepartment = Class.create();
CheckUserDepartment.prototype = Object.extendsObject(AbstractAjaxProcessor, {
isPublic: function() {
return true;
},
isUserInTargetDepartment: function() {
var userId = this.getParameter('sysparm_user_id');
gs.info('Id Usuario: ' + userId);
var userGR = new GlideRecord('sys_user');
if (userGR.get(userId)) {
var deptSysId = userGR.getValue('department');
gs.info('Departamento: ' + deptSysId);
if (deptSysId) {
var deptGR = new GlideRecord('cmn_department');
if (deptGR.get(deptSysId)) {
var structure = deptGR.getValue('u_complete_structure');
gs.info('Estructura: ' + structure);
if (structure.includes('9731')) {
gs.info('Devuelve True');
return 'true';
}
}
}
}
gs.info('Devuelve False');
return 'false';
}
});
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
‎02-19-2025 07:10 PM
Hope you are doing good.
Did my reply answer your question?
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