Need to output array of records from an action

KDWeigel
Tera Expert

I'm experiencing that only sys_id gets outputted in Records output type.
From the documentation i've seen, i need to output only sys_id of record to array and pass that to output variable.
But when trying to get value from other fields in record, it's empty,

 

(function execute(inputs, outputs) {
   
var shiftGr = new GlideRecord("table");
shiftGr.addQuery('state', 108);
shiftGr.query();

var checked = [];
var shifts = [];

while (shiftGr.next()) {
    //gs.info(shiftGr.new_owner.name);
    var newOwner = shiftGr.new_owner.sys_id.toString()
    if(checked.indexOf(newOwner) <= -1) {
        shifts.push(shiftGr.sys_id.toString());
        //shifts.push(shiftGr.toString());
        checked.push(newOwner);
    }
}
outputs.records = shifts;
})(inputs, outputs);
0 REPLIES 0