Join Jess Lopez, Salesforce.org's NGO Technical Architect in Customer Centric Engineering (aka NPSP Surgeon and Detective) as she shares tips and tricks she uses every day when troubleshooting both managed packages and unmanaged customizations in some of the most complex and largest customer orgs. Managed Package examples will be focused on the Nonprofit Success Pack, but concepts can be broadly applied to any package.
You receive a cryptic error. Where do you even start to troubleshoot? In this session, Jess will walk you through capturing a debug log and viewing all sorts of useful information from within the Dev Console. She'll also walk you through some of the more common errors and strategies for troubleshooting
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Debug Log Surgeon
1. Become a Debug Log Surgeon
Taking Your Dev Console Troubleshooting Skills to the Next Level
jess.lopez@salesforce.com, @jjjlo
Jess Lopez, NGO Technical Architect, Salesforce.org Customer Centric Engineering
Forward-Looking Statements
Statement Under the Private Securities Litigation Reform Act of 1995
This presentation may contain forward-looking statements that involve risks, uncertainties, and assumptions. If any such uncertainties
materialize or if any of the assumptions proves incorrect, the results of salesforce.com, inc. or Salesforce.org could differ materially from
the results expressed or implied by the forward-looking statements we make. All statements other than statements of historical fact could
be deemed forward-looking, including any projections of product or service availability, subscriber growth, earnings, revenues, or other
financial items and any statements regarding strategies or plans of management for future operations, statements of belief, any
statements concerning new, planned, or upgraded services or technology developments and customer contracts or use of our services.
The risks and uncertainties referred to above include – but are not limited to – risks associated with Salesforce.org or as applicable
Salesforce (referred to collectively as “we” and “our”) developing and delivering new functionality for our service, new products and
services, our new business model, our past operating losses, possible fluctuations in our operating results and rate of growth,
interruptions or delays in our Web hosting, breach of our security measures, the outcome of any litigation, risks associated with completed
and any possible mergers and acquisitions, the immature market in which we operate, our relatively limited operating history, our ability to
expand, retain, and motivate our employees and manage our growth, new releases of our services and successful customer deployment,
our limited history reselling non-salesforce.com products, and utilization and selling to different market segments. Further information on
potential factors that could affect the financial results of salesforce.com, inc. is included in its annual report on Form 10-K for the most
recent fiscal year and in its quarterly report on Form 10-Q for the most recent fiscal quarter. These documents and others containing
important disclosures are available on the SEC Filings section of the Investor Information section of the Salesforce Web site.
Any unreleased services or features referenced in this or other presentations, press releases or public statements are not currently
available and may not be delivered on time or at all. Customers who purchase salesforce.com services or the Salesforce.com-developed
products and services should make the purchase decisions based upon features that are currently available. Salesforce.org assumes no
obligation and does not intend to update these forward-looking statements.
2. Step 1
Step 5
Step 4
Step 3
Step 2
NPSP /
Managed
Packages
Where might
we find errors?
Order of
Execution &
Governor
Limits
Real World
Example
Common Errors
and Strategies
for
Troubleshooting
Step 6
Agenda
The Dev
Console
Who am I?
I went to college thinking I would become a surgeon.
3. Who am I?
I went to college thinking I would become a surgeon.
Who am I?
Today, I’m a Salesforce.org NGO Architect in Customer Centric Engineering.
4. Who am I? It’s similar… kind of.
Help! NPSP is doing this really strange thing
for a customer and it’s causing them some
major pain and headaches.
Find and resolve the issue quickly!
“
”
“Surgery” “Charts” “Grand Rounds”
It’s similar… kind of.
● Capture logs and
analyze with precision
● Review NPSP
codebase
● Resolve issue;
suggest resolution to
customer; or escalate
to Product team
● Case Escalations
● Investigations
● Github Issue
“Novels”
● Case Studies
● Trainings/
Bootcamps
“Diagnose
Critical Issues”
● Run “tests” and
analyze holistically.
● Determine root
cause
5. NPSP & Packages
NPSP at a Glance
NPSP = Nonprofit Success Pack
Salesforce.org Product; foundation of Nonprofit Cloud
Pre-built constituent and donor management components
Built on Salesforce.com
Flexible, open data architecture
6. Maybe...
Core
Salesforce.com (EE or UE)
Sales Cloud | Service Cloud
SFDO
Nonprofit Success Pack Volunteers for Salesforce
Usually...
Core
SFDO
Declarative and Programmatic Customizations
Managed PackageManaged PackageManaged PackageManaged PackageManaged Package
Salesforce.com (EE or UE)
Sales Cloud | Service Cloud
Nonprofit Success Pack Volunteers for Salesforce
Marketing Cloud Communities
7. Understanding Packages
Unmanaged
● Editable components
● Can’t be upgraded or changed by package owner
once installed
● Can see everything about the package in debug logs
Managed
● Some components are editable; others are not.
● Fully upgradeable
● Push updates
● Can’t see many things about the package in debug
logs
Certified Managed Packages:
● On AppExchange
● Have gone through Security Review
● Get own set of limits for most per-transaction limits
(DML, Query Limits, etc.)
“A package is a container for something as small as an individual component or as large as a set of
related apps. After creating a package, you can distribute it to other Salesforce users and
organizations, including those outside your company.”
Where might we find errors?
8. Record-Level Errors
Email / Chatter Notifications
NPSP Settings →
System Tools → Error
Notifications
● Choose to send to
specific User, System
Admins, or Chatter group
● Typically related to our
Scheduled Jobs
9. Apex Jobs
Errors Custom Object
View and clear logs within NPSP
Settings → System Tools → Error
Logs
Create reports on object, too!
10. Order of Execution
(Super High-Level)
Validation
Before Triggers
Duplicate Rules
Save, but don’t commit
After Triggers
Assignment Rules
Auto-Response Rules
Workflow Rules
Processes / Flows
Escalation Rules
Entitlement Rules
Roll-up Summaries (parents/grandparents)
Criteria-based Sharing Rules
Commit record
Post-commit logic
Governor Limits
11. Limits, Allocations, and Limitations
Allocations
Edition-based
constraints
(e.g. # of Custom
Objects, # of Validation
Rules)
Limits
Concrete numeric values
assigned to
features/functionality
(e.g. Max # of Sharing
Rules)
Limitations
Expected but unavailable
functionality
(e.g. Importing
Documents in the Data
Import Wizard)
Design-Time Limits
Cross-Object Formulas
Lots of vLookup Rules per object
Picklists with lots of values
Lots of Report Filters
Sharing Rules Limits
Criteria-Based Sharing Rules
Max Child Relationships
12. Run-Time Limits
Total # of SOQL Queries Issued
Total # of records retrieved by a SOQL Query
Total # of DML Statements Issued
Total Heap Size
Maximum CPU Time Limit
Maximum Transaction Execution Time
Shared across everything in the transaction
Certified managed packages have their own set
Synchronous vs. Asynchronous
Double or More!
Source: Execution Governors and Limits
Synchronous Asynchronous
Total # of SOQL Queries 100 200
Total Heap Size 6MB 12MB
Max CPU Time 10,000 ms 60,000 ms
Max Async Apex Method
Executions
250,000 (or # of licenses x 200)
Max # of Batch jobs
queued/active concurrently
5
Max # of Records Returned
for Batch Apex query in
QueryLocator
50,000,000
13. Real World Scenario
Let’s break it down.
Record-Level Error
Creating an Opportunity
”NPSP”…
“TDTM_Opportunity…”
“Sounds like an issue
with NPSP… right?!
Or is it…”
14. Enter the Debug Log
View exactly what’s happening
Debug Logs capture database operations, system processes, and errors
• View info on both declarative and programmatic customizations
Debug Levels
Crank it up or Dial it down
● Default =
SFDC_DevConsole
● Segmented categories
15. Creating New Trace Flag for a User
● Setup → Debug Logs: Manually
set debug logging for User,
Automated Process, Apex Class,
or Apex Trigger
● Or if Dev Console open, will
automatically capture.
View the Debug Log
Create an Opportunity again and view the log in Setup --> Debug Logs
16. What’s in a Log Entry?
14:49:59.037 (37045000)|USER_DEBUG|[2]|DEBUG|Hello World!
15:51:01.071 (55856000)|DML_BEGIN|[5]|Op:Insert|Type:Invoice_Statement__c|Rows:1
Debug Log Limits
Each Debug Log = 5 MB before truncation
Retention: System = 1 day; Monitored = 7 days
Total = 250MB in a 15 minute window
17. Debug Log Limits
Each Debug Log = 5 MB before truncation
Retention: System = 1 day; Monitored = 7 days
Total = 250MB in a 15 minute window
Enter the Dev Console
It’s not just for code.
View Logs
Create, view, and edit code
Execute Anonymous
Set/View Checkpoints in code
Query Editor
Query Plan
(Help Menu → Preferences → Enable Query Plan = true)
18. Let’s get a better view in the Dev Console
If not already open, go to Debug → uncheck Show My Current Logs Only
Still not great...
So much text.
NPSP is a managed
package, so you won’t
see some information.
You will still see query
information, general
execution times, etc.
19. What if we just switch our perspective?
Predefined layouts of panels
Dev Console Perspectives
Default View is Log
Only
Switch to All,
Analysis, or Debug
for different views
Save and create
your own
21. Execution Log
Useful for troubleshooting execution times and to see how many records are being returned in
each query
Clicking on Query in Stack Tree, for instance, jumps to line in Execution Log
Execution Overview
Graphical View of Executed Units
22. “Stairway to Heaven”
Execution Overview
Executed Units – with filtering! (Filter to Queries since this is related to Query Limits)
This query might be the issue, since the Count is 100
23. Execution Log
Final Limits
(default)
- your limits
NPSP’s limits
- has own limits as a
certified managed package
Execution Log
Let’s back up a few lines
It wasn’t NPSP after all.
It was custom code in
RogueOpportunityHandler’s
queryPayments() method.
Because NPSP’s Opportunity
trigger kicked it off, it surfaced the
error.
24. Common Errors & Strategies
for Troubleshooting
Too many query rows: 50001
Can’t query for more than 50,000 records at a time ****
Dev Console Strategy
• Execution Overview → Executed Units tab. Filter
to only show Queries. Sort by Row columns
(Descending)
NPSP Scenario:
• Legacy Rollups, Error Notifier
General Strategies
• Avoid data skew; distribute / archive
• Add LIMIT to query
• Add more filters
• If related to a batch job, lower the batch size
25. Too many dml rows: 10001
Can’t insert, update, upsert, delete, undelete, merge more than 10K records at once
Dev Console Strategy
• Execution Overview → Executed Units tab. Filter
to only show DML. Sort by Row columns
(Descending)
NPSP Scenario:
• Recurring Donation => Opportunity Distribution
General Strategies
• Avoid data skew; distribute / archive
• Consider batching
• If related to a batch job, lower the batch size
• NPSP: Lower your Opportunity Forecast Month
Settings or your Batch Size Settings in NPSP
Settings
Apex CPU Timeout
Your execution took too long.
Typically, there’s a lot of automation occurring.
• Lots of triggers
• Lots of packages
• Lots of process builder processes, workflow
rules, flows, validation rules
• Recursion
NPSP Scenario:
• Contact Insertion
• Closed/Won Opportunity Insertion
Strategies
• Lower batch sizes
• Consider ways to optimize code / queries through
best practices and platform options
• This is a shared limit -- so consider ALL that’s
happening for a single transaction.
26. Too many query locator rows: 50000001
Batch Job start() method returned more than 50 million records
NPSP Scenario
• Opportunity Naming Batch Job
• Customizable Rollups Batch Jobs **
Strategies
• Add Limits / filters if applicable
• Consider batch chunking / chaining
• Data Archival
REQUEST_RUNNING_TOO_LONG
Usually the batch job’s start() query has timed out
NPSP Scenario
• Customizable Rollups Batch Jobs **
• Seasonal Address Batch Job **
Strategies
• Make sure query is selective (use Query Plan
tool)
• Consider custom indexes, but code should be
optimized first. There are also thresholds at play.
Skinny Tables, too.
• Reduce data with filters
• Consider batch chunking/chaining
27. Resources
Platform Resources
Salesforce Help
• Logs Tab
• Log Inspector
• Debug Logs
• Debug Log Levels **
• Debug Log Details
• Examples of Using the Log Inspector
• Debug Log Order of Precedence
• Debug Log (Apex Developer Guide)
Trailhead
• Dev Console Basics
• Write Efficient Queries
• Build Efficient Applications without Limits Trail
• Large Data Volumes
• Strategies for Big Data Architecture
• Find and Fix Bugs with Apex Replay Debugger
28. NPSP Resources
General
• Github “Cumulus” Repository and Issues
• General Product Documentation
• Power of Us Hub Groups and Topics
Trailhead
• Administer NPSP Trail
• Fundraise with Nonprofit Cloud Trail
QUIZ!
29. In Spring ‘19, what is the maximum size
of a debug log (in megabytes)?
5 megabytes
30. True or False:
You can view all code from
a managed package in a debug log.
False
31. How do you capture the logs for
a Scheduled Apex Job that starts
running at 4 a.m.?
1. Setup → Debug Logs
2. Create Trace Flag for running user of
Scheduled Job
3. Set the Start Time to 4 a.m.
32. What can you do if your logs are truncated?
(A) Wait until the Summer ‘19 release to start troubleshooting
(B) Delete your previous debug logs
(C) Reduce one or more Category logging levels for your Debug Level
(D) Download the debug log and view it in VS Code
What can you do if your logs are truncated?
(A) Wait until the Summer ‘19 release to start troubleshooting
(B) Delete your previous debug logs
(C) Reduce one or more Category logging levels for your Debug Level
(D) Download the debug log and view it in VS Code
33. True or False:
Flows count toward SOQL Query Limits
True.
Record Update, Record Delete, Record Lookup,
and Fast Lookup count.