Log contents of current in business rule
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-01-2017 09:19 AM
I am debugging an onBefore business rule that fires when a record is created from an external web service call and would like to see the entire contents of 'current'.
gs.info(current);
simply logs that current is an object.
How do I deserialize current so that I can see the contents?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-01-2017 09:38 AM
Hi Bradley,
Use this script in a business rule as you want to deserialize the current object. Verify the logs after it is executed.
logObj(current, '*');
function logObj(obj, sep){
for (x in obj){
if (typeof obj[x] != "function"){
gs.log(sep + x + ":: " + obj[x]);
}
logObj(obj[x], sep + "*" );
}
}
Let me know if it works
Thanks
Please Hit like, Helpful or Correct depending on the impact of the response
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-01-2017 10:13 AM
It partially works. Some values are output, but warnings or errors are displayed in the log
I was hoping to get something that dumps the object in a single entry, e.g., currrent.toJSON(), but this helped.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-01-2017 09:41 AM
This article might help you out - https://www.servicenowguru.com/scripting/business-rules-scripting/checking-modified-fields-script/