The CreatorCon Call for Content is officially open! Get started here.

Debug is not working

Zosy
Giga Contributor

Guys , 

What could be the reason ?? for debug mode  is not working ! 

 

I have chuck of code trying to debug but looks like it's not working ...can someone help me with it ?

 

Many thanks for your help ! 

1 ACCEPTED SOLUTION

Hm the code you've shown doesn't look much like a Script Include to me though.

Try to create a new Script Include and put everything in a function there (even in the 'initialize' should be ok) and add the breakpoints there. 

Afterwards run 'new MYSCRIPTINCLUDE();' in a background script (if you placed the code just inside the initialize function). Then your breakpoints should trigger.

You cannot debug directly from a scheduled job because they will not run in your "Session" (they will run in the background by ServiceNow).

Btw: Please make sure that the Scheduled Job has the proper 'run_as' value (you have to edit this field via list-edit) - by default the user who creates the scheduled job is put in there. But if for some reason this account is ever getting deleted, the scheduled job will no longer run (so you need some kind of technical "ever existing" user account that will run scheduled jobs).

find_real_file.png

View solution in original post

8 REPLIES 8

Markus Kraus
Kilo Sage

Thats very little information you are providing, can you please share the code snippet you are trying to debug?

Is it client side or server side? Are you debugging with gs.info or break points? 

If you are talking about the Script Debugger not opening - try loggin in and out, additionally check if your browser is blocking the popup.

find_real_file.png

Hi Zosy,

The breakpoints seems be set. What is not working? Is the execution not stopping at the breakpoints? Are the values not being displayed?

Chuck has a video on Debugging.

https://www.youtube.com/watch?v=uPXKyTfKW1g

Thanks for your reply. Is a business rule? I think we need more context on e.g. how the execution of this script is triggered.
Additionally as a general improvement, consider using the IIFE-Pattern (Mozilla Doc😞

/*global gs, GlideRecord, sn_compliance */
/*eslint no-undef: "error"*/
(function () {
  
  // put your script in here
  // only if placed in here you will get proper syntax highlighting
  // additionally, thanks to the eslint settings, you will be informed of typos :-)

})();