when debugging a Script Include in the browser, how do I get the server side scripts to show?

edmcpadden
Kilo Explorer

I am having a problem with the Script Include that handles the service side of an Ajax request I am making from within my app.

I remember there being a way to debug the server side code from the browser using but when I do that I don't see any of the scripts when I go to the Javascript Debugger tab (see image below)

CropperCapture[178].png

I remember doing this with some sample tutorials and I was hoping that someone could tell me what I am getting wrong.

Thanks,

...Ed

P.S. I am using the latest version of Chrome, if that matters.

8 REPLIES 8

bernyalvarado
Mega Sage

Hi Ed, the way i often do debugging for server side scripting is in two folds:



1st) I often add various gs.log('++ Workflow: Hello World, we are going to start with...' + current.some_field_name); type of statements. You then go to either System Logs >> System Log >> Script Log Statements if you only want to see yours (and other gs.log entries). This will help you to understand a) the values of the variables at that point of time and b) what flow your script is following. This is sort of an old school way of debugging, but very effectively for me at least .



2nd) You may just want to look into all logs System Logs >> System Log >> All specially to understand if there are any error or warnings taking place when your script is executed. You can filter out any log entries that are irrelevant for your investigation



3erd) Finally, when I have no clue of where the issue may be and specially if I don't want to modify OOB script so I don't take ownership of the records, then I go to System Diagnostics >> Session Debug >> Enable All. On all honesty, i personally believe that it takes some experience to master troubleshooting through all the information that's shared by the session debug; yet, it's definitely useful and through time you will learn to master it!



I hope this is helpful!



Thanks,


Berny


Hi Ed McPadden, can we close this thread by marking the responses as helpful/correct?



Thanks,


Berny


Thanks Berny,



I am still new to ServiceNow and struggling a bit with knowing what is going on in the server side scripts.   I was told by a support person that most people use logging a a way of debugging.  



I was able to get my script to finally show, it seems that I inadvertanly included Angular.js globally without realizing it and the version I included was later than what ServiceNow uses.



But sad to say, after I got that straightened out, I was still not able to debug using it.   The app would hang when I tried to select a script.   So...I'm doing more logging.



Thanks for your response!


...Ed


You're welcome Ed! And have you used the Enable All feature? That's also of great benefit for troubleshooting server side code. If you have a more specific item you will like to debug then just type debug in your navigation bar and you will see a good list of options



Thanks,


Berny