The Zurich release has arrived! Interested in new features and functionalities? Click here for more

How to debug the script includes?

Rajan3
Mega Expert

How to debug the script includes, what are the ways are available. I tried to debug by setting break points in respective lines in script includes but not worked. Please give me a solution. I like to know.

4 REPLIES 4

arielgritti
Mega Sage

Hello

You can create your own script include to debug, similar to this

find_real_file.png

 

And call them like this

find_real_file.png

 

Or add code line like this in the script include:

gs.log('DEBUG = ' + dataToDebug);

 

To see the debug info go to System Logs -> System log -> Script log statements

 

I hope my answer has been useful

Ariel

PS: Please mark my answer correct or helpful if I have helped you. Thanks

Pritha1
Mega Expert

What I do is gs.log in the lines of the script includes where I am having issues to know where the problem is. 

For example I will log the parameter passed from client script to see if the script include got the value. 

var formValue = this.getParameter('sysparm_formValue');

gs.log("Pritha says formValue  " + formValue);

Your logs will appear in Script Log Statements - search this in navigation filter.

 

Ujjawal Vishnoi
Mega Sage
Mega Sage

Hi Ramesh,

 

Put some log statement(gs.log('Any string')) in your script include on those lines where you suspect your code is not working and check how many logs you are getting after calling the script include. Also if you are calling it from BR then you need not to call it again and again by fulfilling the BR's condition. Alternatively you can call it from background script.

 

Hope this helps.

 

Regards

Ujjawal

naveen_kumarhr
ServiceNow Employee
ServiceNow Employee

Check this https://docs.servicenow.com/bundle/orlando-application-development/page/script/debugging/concept/script-debugger.html, this will help you