How to log an Object in ServiceNow?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-20-2021 06:04 AM
var Arrays = Class.create();
Arrays.prototype = Object.extendsObject(AbstractAjaxProcessor, {
diffArrays: function(a1, a2) {
var a = [],
diff = [];
var oldBigger = false;
for (var i = 0; i < a1.length; i++) {
a[a1[i]] = true;
}
gs.log('1a ' + JSON.stringify(a));
gs.log('2a ' + a);
gs.print('3a' + JSUtil.logObject(a));
gs.print('4a' + JSUtil.describeObject(a, 'name'));
gs.log(global.JSON().encode(a))
for (var i = 0; i < a2.length; i++) {
if (a[a2[i]]) {
delete a[a2[i]];
} else {
a[a2[i]] = true;
}
}
for (var k in a) {
gs.log('5a ' + k);
diff.push(k);
}
if (a1 < a2) {
oldBigger = true;
}
return [diff, oldBigger];
},
type: "Arrays"
});
var test = new Arrays();
gs.log(test.diffArrays(["a", "b", "d"], ["a", "b", "c"]));
var array123 = [1, 2, true]
LOG:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-20-2021 10:35 PM
i guess it is the Arguements Part, thats new for me thank you!!!!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-20-2021 11:05 PM
Glad to help.
Always check the docs for the exact function details.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-20-2021 11:06 PM
If my response helped you please mark it correct to close the question so that it benefits future readers as well.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-20-2021 11:31 PM
my Question was to log the Object 🙂 but this does not work
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-20-2021 11:36 PM
Hi,
So for your question to print the array a you can use this line which I already shared yesterday
gs.info(a.toString());
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
