The document discusses using processes and timers to handle long-running asynchronous tasks in Salesforce. It presents several common use cases and provides options for addressing each case. For many smaller transactions, it recommends using staging tables or live queries. For long asynchronous transactions, it suggests status polling or callbacks. For long synchronous transactions, adjusting timeouts, wrapping the call in a separate asynchronous service, or not using asynchronous processes are options. It also discusses updating user status through polling, a notification entity, or email.
Using Processes and Timers for Long Running Asynchronous Tasks in Salesforce
1. | Using Processes and Timers for Long Running Asynchronous Tasks
Using Processes and
Timers for Long Running
Asynchronous Tasks
2. | Becoming a Forge Component Author| Using Processes and Timers for Long Running Asynchronous Tasks
Craig
St. Jean
Engagement Manager | Netlink
@
in
cstjean@netlink.com
/craig-st-jean
3. | Using Processes and Timers for Long Running Asynchronous Tasks| Using Processes and Timers for Long Running Asynchronous Tasks
Problem Description
4. | Using Processes and Timers for Long Running Asynchronous Tasks| Using Processes and Timers for Long Running Asynchronous Tasks
Patterns
5. | Using Processes and Timers for Long Running Asynchronous Tasks
Many Smaller
Transactions
Case:
Merging records in Salesforce
while updating many
individual child records
6. | Using Processes and Timers for Long Running Asynchronous Tasks
Options:
● Staging Tables
● Live Queries
7. | Using Processes and Timers for Long Running Asynchronous Tasks
Staging Tables
Prior to running your
timer, query for all
transactions that need to
be processed and store ids
in a staging table
8. | Using Processes and Timers for Long Running Asynchronous Tasks
Live Queries
Each run of your timer, query for a
new set of transactions that need
to be processed
9. | Using Processes and Timers for Long Running Asynchronous Tasks
One Long
Asynchronous
Transaction
Case:
Placing an order to an external
system that does not accept
the order until a person
verifies stock
10. | Using Processes and Timers for Long Running Asynchronous Tasks
Options:
● Status Polling
● Callbacks
11. | Using Processes and Timers for Long Running Asynchronous Tasks
Status Polling
Every now and then, ask the
backend if the transaction has
completed
12. | Using Processes and Timers for Long Running Asynchronous Tasks
Callbacks
If your asynchronous service
supports callbacks, expose a REST
or SOAP endpoint for it to hit
when the work is complete
13. | Using Processes and Timers for Long Running Asynchronous Tasks
One Long
Synchronous
Transaction
Case:
An automated phone system
that calls the user and
requests inputs
14. | Using Processes and Timers for Long Running Asynchronous Tasks
Options:
● Adjusting Timeout Values
● Wrap the Call in a Separate
Asynchronous Service
● Don’t
15. | Using Processes and Timers for Long Running Asynchronous Tasks
Adjusting Timeout Values
Every timer has a “Timeout in
Minutes” property
16. | Using Processes and Timers for Long Running Asynchronous Tasks
Wrap the Call in a Separate
Asynchronous Service
Expose a service in
a service worker
built for batch
processes.
Add the ability to
check when the
service has
completed its work.
17. | Using Processes and Timers for Long Running Asynchronous Tasks| Using Processes and Timers for Long Running Asynchronous Tasks
Updating User Status
18. | Using Processes and Timers for Long Running Asynchronous Tasks
Why is it important?
Options:
● Polling
● Notification Entity
● E-mail
19. | Using Processes and Timers for Long Running Asynchronous Tasks
Polling
Occasionally query the
Process_System table for your
process’s Status_Id
20. | Using Processes and Timers for Long Running Asynchronous Tasks
Notification Entity
At the end of the process, write a
record to a Notification entity and
give the user a way to read them
21. | Using Processes and Timers for Long Running Asynchronous Tasks
E-mail
Send at the end of your
process
22. | Using Processes and Timers for Long Running Asynchronous Tasks| Using Processes and Timers for Long Running Asynchronous Tasks
Demo
23. | Using Processes and Timers for Long Running Asynchronous Tasks| Using Processes and Timers for Long Running Asynchronous Tasks
Questions?
24. | Becoming a Forge Component Author
Review this (and all attended sessions)
Each review enters
you for a chance to
win a Mavic 2
Drone!
In order to give you the best NextStep next year, please review every sessions you attend in the NextStep app. Even better. Each session you attend and review, gets a chance to win a Mavic 2 drone.