logo

NJP

TechNow Ep 86

Import · Apr 05, 2021 · article

imageJoin us as we dig in to the "wizardly ways" of debugging your code. There are several places you can write code on the Now Platform®. And when you find yourself getting unexpected, or no results, it's time to reach for some debugging tools.

Originally aired: May 25, 2021 8:00 AM PT

  • 00:00 Welcome and introductions
  • 06:29 Poll #1
  • 08:56 Demo start and problem description
  • 13:30 Debugging options
  • 14:47 Introducing script debugger
  • 16:08 Setting a breakpoint
  • 19:02 Other options prior to Quebec
  • 20:30 Introducing Script Tracer
  • 29:31 Andrew's tip: Deactivating files
  • 30:53 Debugging flows
  • 33:21 Introducing Logpoints
  • 37:38 Other tips and tools
  • 39:49 Poll #2
  • 43:08 Upcoming announcements & reference info
  • 45:30 Final Q&A

Links Mentioned

Featured Experts

imageAndrew Barnes is a Developer Advocate in Platform Product Management Marketing at ServiceNow. Focused on growing the quantity and quality of ServiceNow Developers worldwide. Bringing developer feedback into product management for improving the platform for developers. Creator of the largest slack for SN professionals. Co-Host of Live Coding Happy Hour and Creator Toolbox YouTube shows.

imageChuck Tomasi is a Sr. Developer Advocate for ServiceNow. He is a computer science major with over 35 years of IT experience. As a former ServiceNow customer, Chuck won the first Innovation of the Year Award at Knowledge 10. Since joining ServiceNow in 2010 as a Technical Consultant, he has done many large scale ITSM implementations and custom applications, acted as an adjunct instructor for Education Services, created and lead the Technical Best Practices program, makes appearances on Live Coding Happy Hour, created dozens of fit for purpose custom applications, and co-hosts the ServiceNow series "TechNow".

Kreg Steppe is a Sr Staff Enterprise-wide Apps/Sys Developer within ServiceNow Training and Certification developing and supporting cloud training infrastructure. He specializes in developing integration solutions, automating repeatable processes and Cloud Management in ITOM. Kreg's prior experience includes operating his own ISP, developing web applications in PHP, network integration, managing network support, Application Development on cloud based networks, DNS and email server maintenance. He is a Linux enthusiast and enjoys Photography.

Jeremy Duncan is a Platform Architect on the Workflow Design Studio team at ServiceNow. Jeremy is an Enterprise Architect with over 16 years of IT and Service Management experience. His experience and certifications span across retail and manufacturing with focuses on hardware, software, and information security specialties and is a ServiceNow Certified Master Architect. He has done many implementations in both the Enterprise Federal and Commercial spaces since 2011 and brings a breadth of platform knowledge that aids him in sound architectural decisions. He achieved his B.B.A. at MTSU and majored in Information Systems. He spends his free time fighting crime as a volunteer certified police officer in North Nashville since 2012 and enjoys family time, camping, with his wife and kids!

Questions and Answers

would be better if a LOG point would just log out the Previous and Current values for the records being acted on here

Great idea. I invite you to post your idea to the Idea Portal on the community. Our Product Managers review those regularly.

Andrew, I managed over 250 SN Instance for my company I would like to read more about your Update Set tracker might be a good fit for us and our Product Dev

Answered live, thank you for your question!

I am not getting Script Tracer under System diagnostic. Currently we are using Paris version.

Hi Balaji, Script Tracer is a Quebec feature.

tracing has any impact on the system logs space issues?

No. Best practice was demonstrated - use Logpoints where possible to reduce noise in the system logs.

Does logpoints have its own specific properties window, or do we need to enable it directly via sys_properties only?

It appears at this time that there is no category associated with the property which means it cannot appear on a page anywhere - so short answer - you need to edit directly from sys_properties

Is there a more robust code search tool that can also find any given string across the entire instance?

The code search in Studio will do a global search (save a few script fields). Just be sure to check the "Search in all applications" field when searching.

Will the studio search with the checkbox to search in all applications, include the global application?

Yes it does.

can choose script in this and search for the properties?

I'm not sure what the question is here. Sorry. If you can elaborate in the comments, we may be able to assist. Thank you.

Sys_MetaData and Studio search are not true global searches and miss vast swathes of the instance.

I don't know if "vast swathes" is quite right. There are a minority of very specific script fields that are not caught by the global search in Studio. I know this list is modifiable by our developers so if you spot something that you feel should be included, please post it in the Idea Portal on the Community. Thanks.

Are there specific roles associated with granting the ability to do debugging?

Hey Shawn, I know we wavered on this a bit, but there is a specific role for debugging: https://docs.servicenow.com/bundle/quebec-application-development/page/script/debugging/concept/script-debugger.html

We have an in-house built instance-wide string (and multi-string) searcher, but it would be nice for there to be something OOtB

Great point. sys_metadata is a good option if you want a wider search. You're searching a system table with this option, but it's a broad strokes search.

Only users with the script_debugger role can access the Script Debugger.

Thanks again for the info Jon! Sent the user this info: https://docs.servicenow.com/bundle/quebec-application-development/page/script/debugging/concept/script-debugger.html

Add "debugger;" to client side code to pause the script (inserts a break point) in the browser.

Excellent tip. Thanks for sharing.

AWESOME... saves time with Best Practices code clean up!

One of the last things I do before releasing to test/prod is to comment out all my debug statements just so I don't pollute production's log.

Is there debugging guidebook?

Hi Ankit! Check out our developer site for help with debugging each type of code you might find: https://developer.servicenow.com/dev.do#!/learn/courses/quebec/app\_store\_learnv2\_scripting\_quebec\_scripting\_in\_servicenow/app\_store\_learnv2\_scripting\_quebec\_s

Wit the recent MFA implentation for APPRepo it has severly impacted CICD automation

Not sure if this will work, but have you checked to see if there is an API token that can be generated for a credential?

how to get a name of a business rule which is setting a value in a filed?on that field there can be many business rules like 50 brules which is setting the field value by one of the 50 brules.

That's where Script Tracer comes in handy. Watch... :)

View original source

https://www.servicenow.com/community/developer-blog/technow-ep-86-debugging-your-servicenow-code/ba-p/2289949