Output printing as [object object]
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-05-2017 01:58 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-05-2017 02:16 PM
I'd highly recommend using Xplore to read objects.
ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-27-2018 12:26 PM
The simplest way to debug such a value is to serialize it using JSON.
Here is an example when dealing with glide records:
var gr = new GlideRecord('incident');
gr.get('14751599dbb9e740713861f74b961987');
var result = {};
for (var prop in gr) {
result[prop] = gr.getValue(prop);
}
JSON.stringify(result);
You can then gs.info or w.e you need to do.
Simple objects you can just serialize:
var obj = { foo: 'bar' };
gs.info(JSON.stringify(obj));
As others have mentioned if the record already exists you can just use Xplore (extremely useful dev tool).
var gr = new GlideRecord('sys_email');
gr.get('602d2711dbce2f400da080c74b96191c');
gr;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-14-2022 12:57 AM
Hi Kyle,
This seems like a good solution but I've got an issue that I can't seem to resolve.
When I stringify my object, it truncates the string by removing whitespaces. I need to keep the whitespaces though for my query to work. How can I resolve this?
For example it should return this:
{"TOTAL":"5","TYPE":"guest","ID":"\n 498cb221cb91d9829fd77ff04a64beae\n Agent\n "}
But it returns this instead:
{"TOTAL":"5","TYPE":"guest","ID":"\n 498cb221cb91d9829fd77ff04a64beae\n Agent\n "}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-28-2024 03:34 AM