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.

unable to filter the services field after getting service sysid from conf item

ServNowDev
Tera Guru

so far i have a ref qualifer in the services field and it should take as arguement the sysid of the Config Item field once selected

Thomas42_1-1718315907494.png

below is my script include that i tried in a background script and it pulls the sys id, 

getCiServices: function(ciID) {
		if(ciID == ''){
			return;
		}
        var myReturn = [];
        var CIUtil = new CIUtils();

        //get a server record
        var server = new GlideRecord("cmdb_ci");
        server.addQuery("sys_id", ciID);
        server.query();
        if (server.next()) {
            //get the affected services, array of ids
            var serviceIds = CIUtil.servicesAffectedByCI(server.getUniqueValue());
            for (var i = 0; i < serviceIds.length; i++) {
                //get the service record
                var service = new GlideRecord("cmdb_ci_service");
                service.get(serviceIds[i]);
                myReturn.push(service.sys_id);

            }
        }
        return myReturn;
    },

 

1 ACCEPTED SOLUTION

Kris Moncada
Kilo Sage

See if this works for you. Normally when I use a javascript in a reference qualifier, I try to keep it self contained like so.

KrisMoncada_0-1718325149041.png

 

 

 

In your original code, I did notice you are missing a parentheses when referencing the script Include testUtils(). 

 

 

 

View solution in original post

1 REPLY 1

Kris Moncada
Kilo Sage

See if this works for you. Normally when I use a javascript in a reference qualifier, I try to keep it self contained like so.

KrisMoncada_0-1718325149041.png

 

 

 

In your original code, I did notice you are missing a parentheses when referencing the script Include testUtils().