/
Table Driven Trigger Management (TDTM) Setup and Guide

Table Driven Trigger Management (TDTM) Setup and Guide

Create a Trigger Configuration Record

  • Following the instructions from the previous step, you’ll learn how to install the application and access it in Salesforce.

  • Once on the PWR Commons application homepage, observe two tabs labeled ‘Home’ and ‘TDTM’.

  • To access the TDTM homepage, simply click on the ’TDTM’ tab.

  • The TDTM user interface will be visible to the user.

  • On the UI, you’ll notice a dropdown labeled ‘None’, highlighted in red as shown in Figure 8.5.8: None Option.

  • This dropdown allows you to select the object on which the user will create a trigger and metadata record.

Picture1.png
Figure 8.5.8: None Option
  • After selecting the object, clicking the ’New’ button will trigger a warning message prompting you to create a class to proceed with record creation, as highlighted in red in Figure 8.5.9: Create a Class Warning Message.

Picture2.png
Figure 8.5.9: Create a Class Warning Message
  • In order to create the metadata record for a specific object, the user must create an Apex class for the respective object and specify the events. This requires minimal coding effort to be performed within the Salesforce developer console.

  • A pseudo-code is accessible on the user interface through the ‘User Guide’ link highlighted in red, as shown in Figure 8.5.10: User Guide Link. Users can refer to this guide to create the essential Apex class and events for the designated object.

  • Let’s consider an example where the user aims to create an Apex class for the Account object. However, before proceeding, the user must first access the Developer Console.

  • In the Salesforce UI, locate the Setup icon at the top right corner. Click on the Setup icon and select the Developer Console to open it.

  • Within the Developer Console, find the File option in the upper left corner. Click on File, then select New, and then choose the Apex Class option.

  • Provide the name for the Apex class; for example use ’AccountHandler’ as illustrated in Figure 8.5.11: Pseudo Code, highlighted in red. Click on the OK button to proceed.

  • Next, input the name of the object, as indicated in orange colour for the ’Account’ object in Figure 8.5.11: Pseudo Code.

  • Proceed by entering the trigger events, as highlighted in green in Figure 8.5.11: Pseudo Code, such as ’beforeInsert’ and ’beforeUpdate’.

  • Additionally, in this instance, We have included an additional event called ‘afterUpdate’ and save the code

  • Once the Apex class is created, return to the TDTM homepage and refresh the page.

  • Navigate to the ’None’ labeled dropdown on the TDTM UI and select it. Locate the object name ’Account’ as highlighted in red in Figure 8.5.12: Object Selection Dropdown and click on it.

  • After selecting the Account object, highlighted in blue as shown in Figure 8.5.13: New Button, simply click on the ’New’ button, highlighted in red as shown in Figure 8.5.13. New Button, to initiate the creation of the metadata record for the Account object.

 

  • Once clicked on the ‘New’ button, the ‘Create New Trigger Configuration’ form will open, highlighted in red as shown in Figure 8.5.14: Create New Trigger Form.

  • Upon opening the form, the selected object’s name will be visible. Following this, proceed to input the metadata record label into the designated label field.

  • After entering the label, the corresponding API name will be automatically filled in the Name field, as illustrated in Figure 8.5.15: Metadata Label and Name.

  • Navigate to the Implementing Class picklist, where you can choose the class generated with the provided pseudo code. Refer to Figure 8.5.11: Pseudo Code.

  • Locate and select the class named ‘AccountHandler’ from the Implementing Class Picklist, as illustrated in Figure 8.5.16: Implementing Class Picklist.

  • Upon selecting the Implementing Class, the Events multi-picklist will dynamically appear, as it is dependent on the Implementing Class picklist. Refer to Figure 8.5.17: Events Multi-Select Picklist for a visual representation.

  • Choose any event from the list; for instance, let’s opt for the ‘beforeInsert, beforeUpdate, afterUpdate’ events as shown in Figure 8.5.17: Events Multi-Select Picklist, highlighted in red.

  • After choosing the ‘beforeInsert, beforeUpdate, and afterUpdate’ events, proceed to the ‘Run on Field Change’ multi-picklist. This list includes all the fields associated with the selected object, which, in this instance, is the Account object. Refer to Figure 8.5.18: Run on Field Change Multi-Select Picklist, highlighted in red.

  • Now select any field from the list. Let’s select the ‘Annual Revenue’ field as shown in Figure 8.5.19: Selected Fields, highlighted in red.

  • The ’Run on Field Change’ feature is functional only for Before Update and After Update events. If the user selects a field from this option, the trigger will execute only when the selected field is updated on the account.

  • Consider a scenario where a user needs to update the last name on a contact during the Before Update event and then proceed to create an account with the same last name after updating the contact during the After Update event.

  • Furthermore, users can define specific criteria conditions and apply custom logic.

  • They can add necessary conditions such as ’Rating equals Hot’, ’Ownership not equals Pri- vate’, and ’Type equals Prospect’ as illustrated in Figure 8.5.20: Criteria Conditions, high- lighted in blue.

  • Users can also incorporate custom logic according to their requirements, such as ’(1 AND 2) OR 3’, as demonstrated in Figure 8.5.20: Criteria Conditions, highlighted in red.

  • The trigger will only execute if the specified conditions in the criteria are met during creation, updating the record.

  • Then press the Save button to store the metadata record. The saved record will then be visible on the TDTM UI, highlighted in red, as shown in Figure 8.5.21: Metadata Record Creation.

 

  • The created record will also be accessible in custom metadata. To view it, navigate to the Setup menu of Salesforce, search for ‘custom metadata,’ highlighted in green, as shown in Figure 8.5.22: Custom Metadata Records, and select the relevant result highlighted in red, as shown in Figure 8.5.22: Custom Metadata Records.

  • Locate the ‘Trigger Configuration’ option, then click on ‘Manage Records’ within the ‘Trigger Configuration’ section, highlighted in blue, as shown in Figure 8.5.22: Custom Metadata Records.

  • The record generated through the UI will be displayed in the custom metadata, highlighted in red, as shown in Figure 8.5.23: Metadata Record.

  • Upon the initial creation of a metadata record for any object, a corresponding trigger for that object will be automatically generated.

  • To locate the trigger, once more, navigate to the Setup menu. Search for ’apex triggers’ and select the result highlighted in red, as shown in Figure 8.5.24: Apex Triggers.

  • You’ll observe the Apex trigger for the Account object named PWR_Account_V1, highlighted in blue, as shown in Figure 8.5.24: Apex Triggers.

 

Related content

PWR Commons TDTM
PWR Commons TDTM
More like this
What is TDTM in Salesforce?
What is TDTM in Salesforce?
More like this
Edit Trigger Configuration
Edit Trigger Configuration
More like this
Product Features
Product Features
More like this
Bulk Activate or Deactivate Events
Bulk Activate or Deactivate Events
More like this
Manage Execution Sequence
Manage Execution Sequence
More like this