I believe that I’ve got a post from a ways back talking about how to log an object in ServiceNow. Since then, I’ve realized that there are two much easier ways to log out on object.
You can stringify the object before trying to log it, or you can use the JSUtils.logObject() method.
Here is a quick demo script:
var myObject = {
“name”: “Object1”,
“number”: 1
};
var stringObject = JSON.stringify(myObject);
gs.log(“My Test. myObject: ” + myObject);
gs.log(“My Test. stringObject: ” + stringObject);
JSUtil.logObject(myObject);
Here is the output:
Here is the official documentation for the JSUtil.logObject method:
https://developer.servicenow.com/app.do#!/api_doc?v=newyork&id=r_JSUtil-logObject_O_S