Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Advanced reference qualifier not working undefined is not a function

tdh o2
Tera Contributor

Attempting to call a script include from an advanced reference qualifier that queries a table using the value of a string field on the form. Zip field, string, 5 digits. County field, references table that contains all counties in a state and their corresponding zip codes.  Reference qualifier should return all counties associated with the Zip in the string field  or "Out of state" (which is also a record in the counties table) if the Zip does not exist in the table. I'm receiving an error in the system logs com.glide.script.RhinoEcmaError: undefined is not a function.  Also is this script correct to return the values correctly?  Also unclear on how to return Out of State.  This is in the customer service scope.

Current reference qualifier: javascript: new TESTAjaxCountyUtil.getCounties(current.zip);

Script include:

var TESTAjaxCountyUtil = Class.create();
TESTAjaxCountyUtil.prototype = {
    initialize: function() {
    },
    
    getCounties: function (zip) {
        var counties = [];
    
        var grMatch = new GlideRecord('u_m2m_zip_counties');
        grMatch.addQuery('u_zip_code',zip);
        grMatch.query();
        while (grMatch.next()) {
            counties.push(grMatch.u_zip_code.sys_id);
                    
        }
        return 'sys_idIN' + counties;
        
    },
    type: 'TESTAjaxCountyUtil'
};

10 REPLIES 10

tdh o2
Tera Contributor

I've tried it in the customer service scope as well as in the global scope with a qualifier with the same result.