Reference qualifier not calling script include

Brijmohan
Tera Contributor

Hi, I have a requirement in catalog item. I have two variables "Search for people" and "Type keyword for search" based on this I want users should be display in reference fields called "search results" but it is showing all users.

I am using script include and advance reference qualifier but it is not working even no logs are showing in logs table.
Not sure what I am doing wrong.

getFilter: function(type, keyword, selectedUsers) {

        gs.info("GEVN_ONEIDM: type = " + type);
        gs.info("GEVN_ONEIDM: keyword = " + keyword);
        gs.info("GEVN_ONEIDM: selectedUsers = " + selectedUsers);

        if (!keyword || keyword=='' || keyword == 'undefined') {
            gs.info("GEVN_ONEIDM: No keyword entered");
            return 'sys_id=NULL';
        }

        var query = '';

        // SSO search
        if (type == 'sso') {
            query = 'user_nameLIKE' + keyword;
        }

        // First name / Last name search
        if (type == 'first_name_last_name') {
            query = 'first_nameLIKE' + keyword + '^ORlast_nameLIKE' + keyword;
        }

        // Email search
        if (type == 'email_address') {
            query = 'emailLIKE' + keyword;
        }

        // Manager search
        if (type == 'directly_reports_to') {

            gs.info("GEVN_ONEIDM: Searching manager using SSO");

            var mgr = new GlideRecord('sys_user');
            mgr.addQuery('user_name', keyword);
            mgr.setLimit(1);
            mgr.query();

            if (mgr.next()) {
                gs.info("GEVN_ONEIDM: Manager found = " + mgr.name);
                query = 'manager=' + mgr.sys_id;
            } else {
                gs.info("GEVN_ONEIDM: Manager NOT found");
                return 'sys_idISEMPTY';
            }
        }

        // Remove already selected users
        if (selectedUsers) {
            gs.info("GEVN_ONEIDM: Removing selected users");
            query += '^sys_idNOT IN' + selectedUsers;
        }

		if(!query){
			return 'sys_idISEMPTY';
		}

        gs.info("GEVN_ONEIDM FINAL QUERY: " + query);

        return query;
    },

 

 Reference qualifier in search result variable: 

javascript​: new global.GEVN_ONEIDM().getFilter(current.variables.v_search_for_people,current.variables.v_type_keyword_for_search,current.variables.v_people);

 

Screenshot 2026-03-12 003059.png
 
Regards,
Brij
13 REPLIES 13

@Brijmohan 

script include screenshot is incomplete

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

@Ankur Bawiskar Please find attached ss and script.

 

Screenshot 2026-03-12 134310.png

var GEVN_ONEIDM = Class.create();
GEVN_ONEIDM.prototype = Object.extendsObject(AbstractAjaxProcessor, {

    getFilter: function(type, keyword, selectedUsers) {

        gs.info("GEVN_ONEIDM: type = " + type);
        gs.info("GEVN_ONEIDM: keyword = " + keyword);
        gs.info("GEVN_ONEIDM: selectedUsers = " + selectedUsers);

        if (!keyword || keyword == '' || keyword == 'undefined') {
            gs.info("GEVN_ONEIDM: No keyword entered");
            return 'sys_id=NULL';
        }

        var query = '';

        // SSO search
        if (type == 'sso') {
            query = 'user_nameLIKE' + keyword;
        }

        // First name / Last name search
        if (type == 'first_name_last_name') {
            query = 'first_nameLIKE' + keyword + '^ORlast_nameLIKE' + keyword;
        }

        // Email search
        if (type == 'email_address') {
            query = 'emailLIKE' + keyword;
        }

        // Manager search
        if (type == 'directly_reports_to') {

            gs.info("GEVN_ONEIDM: Searching manager using SSO");

            var mgr = new GlideRecord('sys_user');
            mgr.addQuery('user_name', keyword);
            mgr.setLimit(1);
            mgr.query();

            if (mgr.next()) {
                gs.info("GEVN_ONEIDM: Manager found = " + mgr.name);
                query = 'manager=' + mgr.sys_id;
            } else {
                gs.info("GEVN_ONEIDM: Manager NOT found");
                return 'sys_idISEMPTY';
            }
        }

        // Remove already selected users
        if (selectedUsers) {
            gs.info("GEVN_ONEIDM: Removing selected users");
            query += '^sys_idNOT IN' + selectedUsers;
        }

        if (!query) {
            return 'sys_idISEMPTY';
        }

        gs.info("GEVN_ONEIDM FINAL QUERY: " + query);

        return query;
    },

    type: 'GEVN_ONEIDM'
});

 

 

@Brijmohan 

try creating fresh script include and then see

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

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

@Ankur Bawiskar is there any issue with this script include?

@Brijmohan 

looks fine to me.

but why you made this script include client callable?

are you having any other function in that which is being called from GlideAjax?

if not then make that non client callable

if yes then keep it client callable

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