function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
pigginsbpigginsb 

Visibility issues when implementing TDTM from HEDA managed package, using my own trigger

Does anyone have a working example of a trigger and class written to implement the TDTM functionality from the HEDA managed package? I have installed the managed package in a dev org, and I am encountering class visibility issues when I try to save the following trigger, which is modeled after the triggers from the unmanaged version of the package (pulled down from GitHub).
trigger TestObject on Attachment (after delete, after insert, after undelete, 
after update, before delete, before insert, before update) {

    hed.TDTM_TriggerHandler handler = new hed.TDTM_TriggerHandler();  
    handler.run(Trigger.isBefore, Trigger.isAfter, Trigger.isInsert, Trigger.isUpdate, Trigger.isDelete, 
        Trigger.isUnDelete, Trigger.new, Trigger.old, Schema.Sobjecttype.Attachment, 
        new hed.TDTM_ObjectDataGateway());
}
I am using the "hed" namespace, which worked when my class needed to extend TDTM_Runnable, but I am seeing an error due to TDTM_TriggerHandler not being visible. Also, if I use my class that extends TDTM_Runnable, I see the same visibility error with TDTM_ObjectDataGateway.

I really don't need a trigger on Attachment. I just wanted to see how simple it would be to get this working. Does anyone have a working example or some insight to share?
Carlos Ramirez Martinez-EiroaCarlos Ramirez Martinez-Eiroa
Hi there~,

Sorry you didn't get an answer on this sooner. For next time I'd suggest posting at powerofus.force.com, the Salesforce.org community (free to join!). We closely monitor that site, and there is a HEDA specific group in it.

Regarding your question, TDTM_TriggerHandler isn't a global class and thus isn't visible outside the HEDA package. You have to use TDTM_Global_API instead. Thus your trigger would look something like:
 
trigger TDTM_Case on Case (after delete, after insert, after undelete,after update, before delete, before insert, before update) {

hed.TDTM_Global_API.run(Trigger.isBefore, Trigger.isAfter, Trigger.isInsert, Trigger.isUpdate, Trigger.isDelete, Trigger.isUndelete, Trigger.new, Trigger.old, Schema.SObjectType.Case);
}

A simple class that runs as a result of a DML operation on Case would have a signature like this:
 
global with sharing class CaseValidation_TDTM extends hed.TDTM_Runnable {

[...]

}