Automate Tasks with Table-Driven Trigger Management (TDTM)
Learning Objectives
After completing this unit, you’ll be able to:
- Identify use cases for TDTM.
- Discuss TDTM functionality in EDA.
What is TDTM?
Table-Driven Trigger Management (TDTM) is a tool you can use to manage apex triggers. If your next question is “what’s an apex trigger?” we’ve got you. An apex trigger is essentially just an automation that happens behind the scenes. Here are some examples of apex triggers you may have seen in action.
- When you create a contact (leaving the account field blank, as is done in EDA), an apex trigger creates an account.
- When you add a relationship to a contact record, an apex trigger creates the counterpart relationship.
- When you update an address on the contact level, an apex trigger updates the address on the corresponding account level.
So taking it from the top, TDTM helps you manage these apex triggers (behind the scenes automations). The benefits of TDTM are many. Check out this chart for a handful of ways TDTM helps with apex trigger management.
Apex Trigger Management |
How TDTM Helps |
---|---|
Scale
|
Manage many automation features (apex triggers) at once without anything getting jumped and throwing errors |
Order
|
Control the order in which operations execute to help minimize errors |
Flexibility
|
Enable and disable triggers as necessary |
Extensibility
|
Add your own triggers that then function within the EDA infrastructure |
Performance
|
Data updates are more efficient because triggers are streamlined and controlled |
Multiple triggers running at the same time can cause a lot of errors if the order of execution isn’t defined. TDTM is the solution! It organizes and runs triggers in a specific order to streamline and minimize errors. Here’s a visual of how triggers work in Salesforce.
Making Changes to TDTM
TDTM can make life as an admin much smoother and more efficient. Knowing a few TDTM best practices will help even more.
An important part of using TDTM is understanding the Trigger Handler custom object. Fields on the object manage the behavior of the triggers built within the TDTM framework. With just a few clicks, you can change the way your code behaves.
There are a few times when you want to disable, customize, and user-manage code with the Trigger Handler object for the best experience.
Disable code when you:
|
Customize code when you:
|
Opt for user-managed code when you:
|
---|---|---|
|
|
Tip: You can “take over” a trigger by checking “User-Managed’ |
View Trigger Handlers
To see a list of all your institution's trigger handler records, navigate to the Trigger Handlers list view. From here you can view a variety of information about your trigger handlers, including information about the object, class, load order and so on. Only system administrators should have access to the Trigger Handler tab. As a best practice, remove access for all other profiles.
When logged in to your admin profile, follow these steps to view trigger handlers.
- Click the Trigger Handlers tab. Trigger handlers are records just like any other, so you can create list views to filter and sort the records. Select the All list view to see the full list.
- Sometimes the Trigger Handler tab isn't visible by default. If you don't see it, click the More tab. If you still don't see it, from the App Launcher ( ), find and select Trigger Handlers.
- If you want to include a custom apex class in your TDTM architecture, click New from the list view to add a trigger handler for that class.
That was a streamlined introduction to the world of TDTM. There’s much more to learn on this topic so we’ve curated an excellent list of TDTM resources for you, if we do say so ourselves. Conveniently, everything is linked directly below.
Next up, we explore customization in EDA and review the need-to-knows for building on top of EDA.
Resources
- Blog: Advanced Feature Management in Salesforce and Why It's So Important
- Salesforce Help: Table-Driven Trigger Management (TDTM) Overview for EDA
- Salesforce Help: Manage Trigger Handlers for EDA
- Salesforce Help: Disable Trigger Handlers for EDA
- Salesforce Help: Add the User Managed Field to the Trigger Handler Page Layout