5. Complex logic is involved under the hood
“I need to replace my credit card”
Behind Every Interaction Is a Process
Login to
Account
Notification:
Credit Card
on its way
Damaged
or Stolen?
STOLEN
DAMAGED
Dispute
Transactions
Confirm
Address
6. Building Processes Into a Seamless Interaction Is Difficult
And, often leads to backlogs of automation requests
Design
process logic Create user
experience
CODE
Integrate
disparate systems
CODE
7. What is Apex Trigger?
Support for Record Managing
Apex triggers enable you to perform custom actions
before or after events to records in Salesforce
Build Process Driven Logic
Use triggers to perform operations based on
specific conditions
More powerful than others
You can use Apex, SOQL and DML, or call other
custom Apex methods.
11. Trigger Events
To execute a trigger before or after insert, update, delete, and undelete operations,
specify multiple trigger events in a comma-separated list. The events you can specify are:
• before insert
• before update
• before delete
• after insert
• after update
• after delete
• after undelete
Types of Triggers
There are two types of triggers.
• Before triggers are used to update or validate record values before they’re saved
to the database.
• After triggers are used to access field values that are set by the system (such as a
record's Id or LastModifiedDate field), and to affect changes in other records. The
records that fire the after trigger are read-only.
12. Apex Triggers vs Process builder, and others…
Slides from TahoeDreamin18 have been used, thanks to David Lui (sfdc99.com)
13. #TahoeDreamin18
How we’ll do it:
Workflow Rule
Process Builder
Flow
Apex
Four Tools Ten Categories
Functionality
Limits
Scale
Debugging
Speed
Testability
User Experience
Simplicity
Four Grades
Excellent
Good
OK
Bad
Time to Deploy
Risk
14. Workflow Rule
Process Builder
Flow
Apex
#TahoeDreamin18
Category #1: Simplicity
Excellent
Good
OK
Bad
Only two possible outcomes!
Many outcomes, though execution intuitively happens
one step at a time
Almost as crazy as code
Need to learn another language to do this!
18. Workflow Rule
Process Builder
Flow
Apex
#TahoeDreamin18
Category #4: Scale - How extendable is the tool?
Excellent
Your workflow rule can only make one decision!
Call other Processes, Flows, and Apex
Call other Flows and Apex
Unlimited scalability
Bad
Excellent
Excellent
20. Workflow Rule
Process Builder
Flow
Apex
#TahoeDreamin18
Category #6: User Experience - Error Handling
Excellent
This workhorse won’t break
Giant block of red error text
Some situational error handling (fault paths)
Fail elegantly. Fully customizable and hideable
Excellent
Bad
OK
22. Workflow Rule
Process Builder
Flow
Apex
#TahoeDreamin18
Category #8: Speed
Excellent
Mature, rock solid engine. Withstood test of time.
Relatively new tool that runs on unoptimized Apex
Relatively new tool that runs on unoptimized Apex
Finest level speed control
Bad
Bad
Excellent
25. Workflow Rule
Process Builder
Flow
Apex
#TahoeDreamin18
Category #10: Risk - Likelihood of ruining your Salesforce org
Workflow rules never ruined Salesforce
If something breaks, you can fix it quickly
These can get pretty messy, but too new to tell
All bets are off. Many orgs die because of Apex
Excellent
Bad
Good
Excellent
29. Development Environments
Development environments are used strictly for developing and testing apps. These environments
contain test data that are not business critical.
Developer
Edition
Partner Developer
Edition
30. Development
Environment
User Licenses Data Storage
API
Enabled*
Notes
Developer Edition
2 full CRM licenses
3 Force.com
Platform licenses
and more...
5 MB Yes Sign-up is Free!
Partner Developer
Edition
20 full CRM
licenses
20 Force.com
Platform licenses
and more...
250 MB
(about
125,000
records)
Yes
This is a DE org with more
storage, features and licenses.
Free for enrolled partners.
Developer Edition Environments
31. Sandbox Environments
Developer Sandbox Developer Pro Sandbox Partial Copy Full sandbox
Refresh Interval 1 day 1 day 5 days 29 days
Storage Limits
200 MB of data storage
& 200 MB of file storage
1 GB of data storage &
1GB of file storage
5 GB of data
storage & 5GB of
file storage
Same as production
organization
Data Copy Metadata only Metadata only
All metadata and
sample of object
data
All metadata and
data
Sandbox Templates Not included Not included Required Available
33. Production Env and Development Env are Divided
Most companies have separate processes, tools & data
Settings
and tunings
Development Rapid logic
mods
34. Get Started with the Developer Console
The Developer Console is an integrated development environment (more typically called an IDE)
where you can create, debug and test apps in your org
Navigate, open, create and edit
Apex classes and triggers
Aura Components
Visualforce pages and components
Browse packages
Generate logs
Test
Checkpoints
SOQL and SOSL Query Editor
36. Generate and Analyze Codes
Using the Developer Console, you can look at various debug logs to understand how your code
works and to identify and performance issues.
Logs
Debug Logs
Log Inspector
Manipulate Log Data
37. Inspect Objects at Checkpoints
Checkpoints show you snapshots of what’s happening in your Apex code at particular points during
execution
Checkpoints
Set Checkpoints in Apex Code
Checkpoints Tab
Checkpoint Inspector