Built something you're proud of? Tell the story. A quick G2 review of App Engine or Build Agent helps other developers see what's possible on ServiceNow. Share your experience.

Unable to print object value of Script Include in System Logs? How to print object value in Sys Log?

VIKAS45
Tera Guru

Unable to print object value of Script Include in System Logs? How to print object value in Sys Log?

2 REPLIES 2

Sandeep Rajput
Tera Patron

use JSON.stringify(obj); to print object value in System log.

 

Example 

 

// obj is a JSON formatted object
var str =  JSON.stringify(obj);
// str is a string containing content to be turned into a JSON formatted object
gs.info(str);

 

 

Source: https://developer.servicenow.com/dev.do#!/reference/api/tokyo/server_legacy/c_JSONAPI

 

Hope this helps.

 

 

_Gaurav
Kilo Sage

Hi @VIKAS45 

You can use gs.log('Unique name to identify the value in logs '+variable);
Also if the var is array type then var.toString() or JSON then use JSON.stringify(var);

Please mark this as helpful if this resolves your query.
Thanks!