Custom Trigger Setup


To set up custom triggers, you need the following permissions:

  • Minimum permissions for the FieldFX modules you are using

  • System permissions:

    • Customize Application

    • View Setup and Configuration


FieldFX features a number of standard triggers that get installed with FieldFX packages.

Refer to the FieldFX Managed Packages article for more information.

You can add custom triggers to extend standard functionality.

TDTM (Table-Driven Trigger Management) for Custom Triggers

  • The global abstract class TDTM_TriggerHandler in the FX5 managed package provides a hook for custom triggers.

  • If a custom trigger handler apex class extends TDTM_TriggerHandler, some minimum setup allows custom codes to plug into the FX5 TDTM trigger flows.

  • Triggers execute in a specified order.

Adding a Custom Trigger

The examples are for illustration only, and illustrate adding a trigger to the FX5__Job__c object.

Code a Global Trigger Handler Class

  • Make the Apex class global.

  • The name must end with TriggerHandler and must not exceed 40 characters (excluding the TriggerHandler suffix).

    For example, LFW_JobTriggerHandler.

    The class name is used to set the Label field of Custom Metadata FX5__TDTMTrigger__mdt.

    For a class called LFW_JobTriggerHandler, the Label for its FX5__TDTMTrigger__mdt is LFW_Job.

    Do not use a lengthy Apex class name. The class name must be shorter than 40 characters + TriggerHandler.

  • Trigger handler Apex class must extend FX5.TDTM_TriggerHandler or implement FX5.ITDTM_TriggerHandler.

  • Apex classes authored by FieldFX by ServiceMax personnel should use a prefix, such as LFW. This helps the support team identify if a trigger is authored by a FieldFX employee.

  • Example:

    global with sharing class LFW_JobTriggerHandler extends FX5.TDTM_TriggerHandler {
        global LFW_JobTriggerHandler()
        global override void onBeforeInsert(List<sObject> items)
        //global override void onBeforeUpdate(List<sObject> objs, Map<Id, sObject> oldmap) {}
        //global override void onBeforeDelete(List<sObject> objs) {}
        //global override void onAfterInsert(List<sObject> objs) {}
        //global override void onAfterUpdate(List<sObject> objs, Map<Id, sObject> oldmap) {}
        //global override void onAfterDelete(List<sObject> objs) {}
        //global override void onAfterUndelete(List<sObject> objs) {}
    //The service class doesn’t need to be global, public will work.
    public with sharing class LFW_JobService {
        public static void initJobs(List<FX5__Job__c> jobs) {

Enable Apex Setting

  1. From Setup, go to Custom Code → Apex Settings.

  2. Enable Deploy Metadata from Non-Certified Package Versions via Apex.

  3. Click Save.

Run Script

  1. Access the Developer Console.

  2. Copy and run the following script.

  3. This script creates a FX5__TDTMTrigger__mdt entry for each trigger operation at the custom trigger handler Apex classes.

Modify the Trigger Execution Sequence

  1. From Setup, go to Custom Code → Custom Metadata Types.

  2. Click Manage Records next to TDTM Trigger.

  3. Click Edit next to the TDTM Trigger to modify.

  4. Change the Sequence Number to the desired value.

    Smaller numbers execute earlier.

    Unless required, leave the Managed Package Trigger Handler’s Sequence Number at 10. If you need a trigger to run before a managed trigger, give it a value less than 10. If you need it to run after a managed trigger, give it a value greater than 10.

  5. Click Save.

Set Active, Allowlist, and Blocklist

  • ALLOWLIST: comma separated list of user login names

    Trigger always runs even if the TDTMTrigger__mdt is inactive

  • BLOCKLIST: comma separated list of user login names

    Trigger at TDTMTrigger__mdt entry does not run for specified users

  • ACTIVE: false

    Trigger does not run except for users in ALLOWLIST