Console.Log() functionality within SN?

Mason Angus
Giga Contributor

I am new to ServiceNow development and I am having trouble testing because I can't figure out how to print to the "console" or any type of console adjacent. I am used to being able to console.log() when testing javascript code to check values, but I am not sure what I should be doing in SN. 

1 ACCEPTED SOLUTION

MrMuhammad
Giga Sage

There are multiple different debugging logs available in servicenow for client side and server side scripts. console.log() can be used on client side script only. in addition we have JSLOG(), alerts etc. On server side we have gs.info, gs.warn, gs.log etc and server logs generates in System Logs > System Log > All.

For more information regarding Servicenow debugging and debugging best practices please refer below

https://developer.servicenow.com/dev.do#!/guides/orlando/now-platform/tpb-guide/debugging_best_pract...

I hope this helps!

 

Thanks & Regards,

Sharjeel

Regards,
Muhammad

View solution in original post

2 REPLIES 2

MrMuhammad
Giga Sage

There are multiple different debugging logs available in servicenow for client side and server side scripts. console.log() can be used on client side script only. in addition we have JSLOG(), alerts etc. On server side we have gs.info, gs.warn, gs.log etc and server logs generates in System Logs > System Log > All.

For more information regarding Servicenow debugging and debugging best practices please refer below

https://developer.servicenow.com/dev.do#!/guides/orlando/now-platform/tpb-guide/debugging_best_pract...

I hope this helps!

 

Thanks & Regards,

Sharjeel

Regards,
Muhammad

For anyone new to ServiceNow (like myself) the editor will highlight client side script lines with a `!` when using console.log().  It will still run regardless of this.