Comments on: OnChange Catalog Client Script Nuance https://servicenowguru.com/client-scripts-scripting/onchange-catalog-client-script-nuance/ ServiceNow Consulting Scripting Administration Development Thu, 07 Mar 2024 20:05:32 +0000 hourly 1 https://wordpress.org/?v=6.8.2 By: Mark Stanger https://servicenowguru.com/client-scripts-scripting/onchange-catalog-client-script-nuance/#comment-6184 Mon, 18 Apr 2011 06:10:15 +0000 https://servicenowguru.wpengine.com/?p=553#comment-6184 In reply to Peter Oneppo.

Thanks Peter,

I remember this giving me fits when I first came across it. Good tip!

]]>
By: Peter Oneppo https://servicenowguru.com/client-scripts-scripting/onchange-catalog-client-script-nuance/#comment-6183 Sun, 17 Apr 2011 21:10:06 +0000 https://servicenowguru.wpengine.com/?p=553#comment-6183 Somewhat along these lines is a “feature” I discovered with pushing sys_ids into an array while looping through a GlideRecord. Here’s what I had at first:

 
var ids = new Array();
 
var gr = new GlideRecord("incident");
 
gr.query();
 
while(gr.next()) {
 
   ids.push(gr.sys_id);
 
}
 

When I was done, every value in the array was the same. They were all equal to the sys_id of the last Glide Record that was found. This is because “gr.sys_id” is an object, so what you end up with is a bunch of pointers in your array all pointing to gr.sys_id, which contains that last sys_id.

I solved the problem by changing my code to this:

 
ids.push(gr.sys_id.toString())
 

This should work too:

 
ids.push(String(gr.sys_id));  
 

You might need a “new” before “String”.

I hope that helps someone out there!

]]>