- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-26-2017 09:40 AM
Hi guys,
In my custom Customer table how can I get sys_id for each record?
var gr = new GlideRecord("x_11111_notes_customers");
gr.addActiveQuery();
gr.orderByDesc('sys_updated_on');
gr.query();
data.customers = [];
while(gr.next()){
var customer = {};
customer.id = gr.sys_id;
customer.name = gr.getDisplayValue('name');
data.customers.push(customer);
}
This code in line #10 returns nothing.
Where I am wrong?
Thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-26-2017 11:34 AM
No on service portal gr.getDisplayValue("sys_id"), it only works.
customer.id = gr.sys_id+'' and customer.id = gr.getValue('sys_id') all are not working.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-26-2017 11:34 AM
Not yet. Will try tomorrow. sys_id +'' - LOL is it a bug in SN?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-26-2017 11:38 AM
It is same as toString().
In your previous scenario when you were using customer.id = gr.sys_id then in this case you were actually assigning an object to customer.id. However you were expecting the value of sys_id. That was the issue.
Hope this helps.
Regards
Ujjawal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-26-2017 11:34 AM
No on service portal gr.getDisplayValue("sys_id"), it only works.
customer.id = gr.sys_id+'' and customer.id = gr.getValue('sys_id') all are not working.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-27-2017 05:25 AM
Thanks. It works.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-26-2017 11:18 AM
Ivan,
When I have encountered this issue in the past what you need to do is either convert the sys_id to a string gr.sys_id.toString() or get the display value gr.getDisplayValue("sys_id") of the sys_id. I am not really sure why you need to do it this way but this is how I was able to resolve it when I ran into it,
Code Example:
data.customers = [];
var gr = new GlideRecord("x_11111_notes_customer");
gr.addActiveQuery(); gr.orderByDesc("sys_updated_on");
gr.query();
while(gr.next()){
customer = {};
customer.id = gr.getDisplayValue("sys_id");
customer.name = gr.getDisplayValue("name");
data.customers.push(customer);
}
Hope this helps..
Freddie