The Now Platform® Washington DC release is live. Watch now!
When you're using GlideRecords in JavaScript, getting properties on the GlideRecord instance may not do exactly what you think they do — and this difference can get you in trouble! For example, consider this little snippet of code:
var map = {};
var gr = new GlideRecord('cmdb_ci_server');
gr.query();
while (gr.next()) {
map[gr.name] = gr.ip_address;
}
for(var name in map) {
gs.log(name + ': ' + map[name]);
}
var map = {};
var gr = new GlideRecord('cmdb_ci_server');
gr.query();
while (gr.next()) {
map[gr.name] = gr.getValue('ip_address');
}
for(var name in map) {
gs.log(name + ': ' + map[name]);
}
// just replace gr.ip_address with any of these:
gr.getValue('ip_address')
new String(gr.ip_address)
'' + gr.ip_address
gr.ip_address.toString()
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.