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.

reference qualifier shows only one value even though I have a lot returning

samadam
Kilo Sage

I am setting a reference qualifier using script include, I have multiple values returning in the array but only shows one value in the reference field. when i print to logs I can see multiple sys_ids. Any idea how to fix?

           var OArray1 = [];
            var ga1 = new GlideRecord('office_space');                 
            ga1.addEncodedQuery('u_active=true^level=2');
           ga1.query();
            while (ga1.next()){
               OArray1.push(ga1.sys_id);
            }
           return 'sys_idIN' + OArray1;
1 ACCEPTED SOLUTION

Sumanth16
Kilo Patron

Hi @samadam ,

 

Can you update your script as belows:

 

var Filterofficespace = Class.create();
Filterofficespace.prototype = {
initialize: function() {
},


Filterofficespace:function(){
var gp = [];
var xyz = current.u_name;

if(!xyz)
return;
if(xyz){
var gr = new GlideRecord('cmdb_ci');
gr.addQuery('assigned_to', current.u_name);//replace with your query
gr.query();
while(gr.next()) {
gp.push(gr.sys_id.toString());

}
return 'sys_idIN' + gp;
}
},
type: 'Filterofficespace'
};

 

If I could help you with your Query then, please hit the Thumb Icon and mark it as Correct !!

 

Thanks & Regards,

Sumanth Meda

View solution in original post

2 REPLIES 2

Sumanth16
Kilo Patron

Hi @samadam ,

 

Can you update your script as belows:

 

var Filterofficespace = Class.create();
Filterofficespace.prototype = {
initialize: function() {
},


Filterofficespace:function(){
var gp = [];
var xyz = current.u_name;

if(!xyz)
return;
if(xyz){
var gr = new GlideRecord('cmdb_ci');
gr.addQuery('assigned_to', current.u_name);//replace with your query
gr.query();
while(gr.next()) {
gp.push(gr.sys_id.toString());

}
return 'sys_idIN' + gp;
}
},
type: 'Filterofficespace'
};

 

If I could help you with your Query then, please hit the Thumb Icon and mark it as Correct !!

 

Thanks & Regards,

Sumanth Meda

Reus
Tera Expert

Hi @Sam 

Try to replace this line 'OArray1.push(ga1.sys_id);' with 'OArray1.push(ga1.sys_id.toString());' and check. Also can add the log statement (gs.log(OArray1)) before the return.