Array.push() replaces all array values with the last value pushed when using GlideRecord fieldsIssue When adding new values to an array using Array.push() with GlideRecord field references, all values in the array are replaced by the last value pushed. The following sample script demonstrates the issue. Run it in Scripts - Background on a ServiceNow instance to fetch all open P1 incidents in the Software category. Sample ScriptSample Outputvar criticalIncident = [];var inc = new GlideRecord('incident');inc.addActiveQuery();inc.addQuery('priority', '1');inc.addQuery('category', 'software');inc.query();gs.info("Total Records: " + inc.getRowCount());while (inc.next()) { gs.info("Incident Number: " + inc.number); criticalIncident.push(inc.number);}gs.info("Critical Incidents: " + criticalIncident);*** Script: Total Records: 5*** Script: Incident Number: INC0000015*** Script: Incident Number: INC0000051*** Script: Incident Number: INC0000052*** Script: Incident Number: INC0000054*** Script: Incident Number: INC0009005*** Script: Critical Incidents: INC0009005,INC0009005,INC0009005,INC0009005,INC0009005 In the sample output, printing the criticalIncident array shows that all values are replaced by the last value pushed. Release Any Cause This behaviour occurs on the ServiceNow platform because Array.push() requires a primitive string value. The Array.push() method has to be passed a String value, else it will override all values in the array to the last value pushed. Resolution Convert the GlideRecord field reference to a primitive string before pushing it into the array. Use toString() so that the resolved string value is stored rather than a live object reference. Sample ScriptSample Outputvar criticalIncident = [];var inc = new GlideRecord('incident');inc.addActiveQuery();inc.addQuery('priority', '1');inc.addQuery('category', 'software');inc.query();gs.info("Total Records: " + inc.getRowCount());while (inc.next()) { gs.info("Incident Number: " + inc.number); criticalIncident.push(inc.number.toString());}gs.info("Critical Incidents: " + criticalIncident);*** Script: Total Records: 5*** Script: Incident Number: INC0000015*** Script: Incident Number: INC0000051*** Script: Incident Number: INC0000052*** Script: Incident Number: INC0000054*** Script: Incident Number: INC0009005*** Script: Critical Incidents: INC0000015,INC0000051,INC0000052,INC0000054,INC0009005