Skip to main content
Content Starts Here
This is a publicly shared Knowledge Article from the Power of Us Hub - an online community for nonprofit and higher ed Salesforce users. Join the Hub.
Product Documentation

Disable Trigger Handlers for HEDA

Note
If you need a refresher on the fundamentals of TDTM, read Table-Driven Trigger Management Overview.

For custom code, a large data import, or an external integration to run successfully, you might need to permanently or temporarily disable TDTM Trigger Handlers. For example, you can disable a Trigger Handler to:

  • Temporarily disable certain Apex classes when inserting a large volume of records with data that is already structured in its final format.
  • Disable Address-related Apex code when inserting or updating Contacts through a scheduled ETL job that always runs as a specific User.
  • Prevent the Primary Account lookups from changing on a Contact when that Contact meets certain criteria (such as Deceased=True).

In these situations, disabling Trigger Handlers is easy to do. No code is necessary!

When you disable a Trigger Handler, you disable the functionality of the Apex class that the Trigger Handler is associated with through the Class field.

For example, the ADDR_Addresses_TDTM class is managed by a Trigger Handler record. ADDR_Addresses_TDTM handles certain aspects of address changes between the Address object, related Contacts, and Accounts.

ADDR_Addresses_TDTM Trigger Handler record

It's helpful to know what each of the Apex classes do, so that you know which Trigger Handlers to disable. Visit HEDA Codebase Documentation for a description of the Apex classes managed by TDTM—classes with the _TDTM extension in the name. Note that there are some classes that are not managed by TDTM, such as utility and settings classes.

Important
Be careful when changing Trigger Handler records. They're designed to work in conjunction, and changing or disabling them can lead to undesirable results. Always test in a Sandbox environment before changing Trigger Handlers in production!

Disable a Trigger Handler for All Users

You would typically disable a Trigger Handler for all users if:

  • You have a custom process or custom code that replaces the functionality.
  • You have a use case that requires that the standard behavior of an Apex class does NOT occur for all users.

To disable a Trigger Handler:

  • Uncheck the Active checkbox to disable a Trigger Handler and the Apex class associated with it.
  • For all HEDA-packaged Trigger Handlers, check the User Managed checkbox to prevent the Trigger Handler from re-activating during the next update of the package. This is important because with each release, HEDA automatically runs a process to check Trigger Handler configuration. If a packaged Trigger Handler is missing or has been changed by a user, the update process will reset those records to the default configuration.

Active unchecked and User Managed checked

To re-activate a Trigger Handler, check the Active checkbox and uncheck User Managed.

Visit the HEDA group in the Power of Us Hub to stay informed on new releases.

Disable a Trigger Handler for Specific Users

In cases where you have a custom integration with another system or need to perform periodic imports of data where you don't need certain Trigger Handlers to run, you can disable a Trigger Handler for specific users. For example, if you have an external data source that already supplies the Account you want for Contacts that are part of the import, you don't need to run the ACCT_IndividualAccounts_TDTM class. The user(s) that run your import or integration can then be excluded from the appropriate Trigger Handler records.

Note
As a best practice, you should dedicate a user account, called an API User, for your integrations. That way, if an actual user leaves your organization, you'll always have an active user with the correct permissions available. Read Create a Secure Salesforce API User in Salesforce Help for more information.

To disable Trigger Handlers for specific users, enter one or more usernames, separating each with a semicolon, in the Usernames to Exclude field.

Usernames to Exclude populated

Going forward, this Trigger Handler will not run for any User whose username is listed in this field.

Note
If you don't see the Usernames to Exclude field, you may need to add it to your page layout and assure it's visible through field-level security.

Disable a Trigger Handler by Field Criteria

You can disable a Trigger Handler based on the value of a field found on the object that the Trigger Handler is associated with, or a field value on a related record. The HEDA Trigger Handler object contains two fields, Filter Field and Filter Value. Together, they allow you to disable a Trigger Handler when the value of a given field is present on a record.

For example, let's say that if a Contact's Title = Board President, you don't want the standard email and phone fields to update when the custom email and phone fields such as Home Phone, Work Phone, University Email, change. You plan to manage the standard email and phone fields manually in this example.

Filter Field and Filter Value populated

Find the Trigger Handler that controls this aspect of the platform automation. The Class field often provides a clue, but you can also read the HEDA Codebase Documentation for more details. In our example, the Trigger Handler we want is CON_Preferred_TDTM.

Note
As a best practice, check the User Managed checkbox if you are modifying a HEDA Trigger Handler record.

When working with Filter Field and Filter Value:

  • You can use only one field and one value for Filter Field & Filter Value.
  • Use the API Name for Filter Field (such as FirstName, MailingCity, Citizenship__c).
  • If you use a HEDA packaged custom field, do not include the namespace prefix. For example use Citizenship__c not hed__Citizenship__c.
  • If you use a third-party packaged custom field, DO include the namespace prefix.
  • For Filter Value, the match is an exact character match. There aren't options for conditionals such as contains, starts with, and so on. However, the text is not case sensitive. New York City and new york city are evaluated the same way.
  • For checkbox fields, use True or False in the Filter Value field.
  • Fields on related records can be used in Filter Field. For example, on a Contact Trigger Handler, you can use Account.BillingCity.
  • Leave Filter Value blank if you want to filter on a blank (null) value.
  • Compound fields such as Address and Geolocation are not supported.

Disable a Trigger Handler in Apex

Note
This section is intended for developers and advanced admins who are familiar with Apex. The bottom line is that you can temporarily disable a Trigger Handler with code instead of editing the Trigger Handler records manually. If the options for disablement discussed earlier in this article don't address your use case, know that you can manage Trigger Handlers with code, too.

Sometimes it's necessary to temporarily disable specific Trigger Handlers only during the execution of Apex code. To achieve this, HEDA uses the TDTM_Global_API class and its tdtmToken method that mirrors the fields on the Trigger Handler object. As such, you can disable Trigger Handlers directly in your code and only for the execution context of the current user.

The tdtmToken method has the following behaviors:

  • Changes made to tdtmToken values persist throughout the execution context for the current User.
  • Changes made to tdtmToken do not impact other Users working in the org at the same time.
  • Changes made to tdtmToken are not committed to the database by HEDA.

See HEDA Codebase Documentation for more information on the TDTM_Global_API class.

Code example:


for (hed.TDTM_Global_API.TdtmToken tdtmToken : hed.TDTM_Global_API.getTdtmConfig()) {       
    // disable for a specific trigger handler class
        if (tdtmToken.className == 'REL_Relationships_Con_TDTM') {
            tdtmToken.active = false;
        }
    // disable for an entire object
         else if (tdtmToken.targetObject == 'Contact') {
            tdtmToken.active = false;
        }        
    // disable all HEDA-provided trigger handlers
         else if (tdtmToken.ownedByNamespace == 'hed') {
            tdtmToken.active = false;
        }
        
    }
Note
Order of execution is important here. Let's say you create your own Apex trigger on the Contact object that disables all the Trigger Handlers on Contact. There is no guarantee that your trigger will run before or after TDTM does. Dealing with this scenario will vary depending on your specific use case. Consider execution order carefully in your code design.