console.log() in a widget server script

Giles Lewis2
Kilo Expert

If I execute console.log() in a background script I get a javascript error (console is not defined). But in a widget server script, the message appears in the Chrome console. What's up with that?

1 ACCEPTED SOLUTION

praveenmuramal1
Kilo Expert

ServiceNow realized console.log is a common javascript function that is used by angularjs and incorporated the functionality of console.log in the widget server script to print in the browser's console.



when they developed background scripts application - the thought of implementing console.log might never cross their minds as they implemented gs.log and printing something in the browser's console doesn't add any value.


View solution in original post

3 REPLIES 3

praveenmuramal1
Kilo Expert

ServiceNow realized console.log is a common javascript function that is used by angularjs and incorporated the functionality of console.log in the widget server script to print in the browser's console.



when they developed background scripts application - the thought of implementing console.log might never cross their minds as they implemented gs.log and printing something in the browser's console doesn't add any value.


"printing something in the browser's console doesn't add any value"

Well, how do I use gs.log to log an object in a way that I can navigate it the way console.log does?

find_real_file.png

This is one of my current learning pains; it's so easy to inspect objects with console.log, but now I need to find a server-side alternative for my server-side scripts.

What would you all suggest, please? Thanks!

Do you want to try ServiceNow Script debugger ? If you want, check this 3 min video - https://youtu.be/drzwGy9OtbY?t=32

Last time I checked it only works in interactive mode.

 

find_real_file.png