Script Include no running

Garvia
Tera Contributor

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!

8 REPLIES 8

Ankur Bawiskar
Tera Patron
Tera Patron

@Garvia 

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.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

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'; 
    }
});
 

@Garvia 

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.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

@Garvia 

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.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader