You are here:
Table-Driven Trigger Management (TDTM) Overview
Understand how EDA uses TDTM to manage your code in Salesforce and control how Apex behaves.
- Introduction
Table-Driven Trigger Management (TDTM) is a tool to manage your code in Salesforce and control how Apex behaves. Apex is the programming language used to build complex automation in Salesforce, and TDTM is a framework for managing that code. - What Is TDTM?
Table-driven trigger management (TDTM) is a tool for automation—and automation is one of the big benefits of using Salesforce. - Disable Specific Pieces of Code
Disable code related to your automated processes to control whether and when certain pieces of code operate. - Create Your Own Custom Code
If you're developing your own custom Apex code or integrating an external system with Salesforce, you should familiarize yourself with the TDTM architecture. Salesforce and many expert developers recommend that you have only on one trigger for each object (one for Contacts, one for Accounts, and so on). - Control the Order in Which Your Code Executes
If your organization has been using Salesforce for a while, it's likely that you'll identify where more automation could save time. While tools like Process Builder and workflow can do some of these things, custom Apex code is sometimes more appropriate. As you develop custom code, it becomes really important to manage the order in which your code fires, which is why TDTM is so helpful. - Summing Up
TDTM allows organizations to grow and more easily add complexity to their databases while still maintaining control over the scope and sequence of process automation.
Introduction
Table-Driven Trigger Management (TDTM) is a tool to manage your code in Salesforce and control how Apex behaves. Apex is the programming language used to build complex automation in Salesforce, and TDTM is a framework for managing that code.
We're here to demystify TDTM—what it is and why it's such a powerful tool for nonprofits and educational institutions using applications like Nonprofit Success Pack (NPSP) and Education Data Architecture (EDA) from Salesforce.org.
What Is TDTM?
Table-driven trigger management (TDTM) is a tool for automation—and automation is one of the big benefits of using Salesforce.
For example, when a Contact record in Salesforce is added, updated, or deleted, we often want other things to happen automatically—update an address or a value on an Account. You may be familiar with using Process Builder or workflows in Salesforce to automate business processes. Some of the more complex processes are built with another automation tool called Apex triggers. Apex triggers are simply another way of handling automation, using code rather than a feature like workflow.
NPSP EDA relies heavily on triggers. For example, a trigger on the Contact object can automatically update address data when the Contact is updated. Other triggers are used to roll up or summarize data from related records to a parent record. Triggers come standard with NPSP EDA, and TDTM is the framework for managing them.
In practice, TDTM has several uses. TDTM lets you:
- Disable specific pieces of code
- Build your own custom code that works in conjunction with NPSP EDA
- Control the order in which the code executes
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.
Disable Specific Pieces of Code
Disable code related to your automated processes to control whether and when certain pieces of code operate.
You might need to disable code when you:
- Import large sets of data (many thousands of records at once)
- Integrate with external systems
- Troubleshoot code errors
Create Your Own Custom Code
If you're developing your own custom Apex code or integrating an external system with Salesforce, you should familiarize yourself with the TDTM architecture. Salesforce and many expert developers recommend that you have only on one trigger for each object (one for Contacts, one for Accounts, and so on).
It's easy to mistakenly create new triggers and end up with many triggers for the same object, which is absolutely not a Salesforce best practice. When you learn how to extend TDTM functionality into your code, you don't need to create new triggers—you just use the trigger that already exists in TDTM to pass environment data to your custom Apex classes. By using the existing TDTM infrastructure instead of creating your own, you get the most reliable and efficient behavior as a result.
Control the Order in Which Your Code Executes
If your organization has been using Salesforce for a while, it's likely that you'll identify where more automation could save time. While tools like Process Builder and workflow can do some of these things, custom Apex code is sometimes more appropriate. As you develop custom code, it becomes really important to manage the order in which your code fires, which is why TDTM is so helpful.
TDTM ensures that things happen in the order you expect them to happen. For example, you wouldn't put on your shoes without putting your socks on first, right? TDTM lets you tell Salesforce to ALWAYS put the socks on first, then the shoes, and so on. Otherwise, things happen in an indeterminate order, which is really just a fancy way of saying that potentially you could end up wearing your socks over your shoes (or have one piece of code firing before another, and not in the order you want). Apex triggers do not come with a way to control the order of operation but TDTM fills that gap.
Summing Up
TDTM allows organizations to grow and more easily add complexity to their databases while still maintaining control over the scope and sequence of process automation.
If the examples we've covered don't sound like the sorts of things your organization is doing now, or you only partially followed what we're talking about, then chances are it's OK for you to leave the default TDTM behavior as is. However, organizations do change over time and you may find that you need to engage with TDTM down the road. Just put a pin in it for now and remember its intended use for the future.

