0

I am looking for a generic solution that would allow instead of creating triggers for each platform event to create one and in some way forward to it. If this even possible and what pattern should I use?

1 Answer 1

1

You have to create one per event type, but you can consolidate the logic to a single utility class:

trigger demoEvent1 on Event1__e (after insert) {
  TriggerUtil.handleEvent(Trigger.new);
}

trigger demoEvent2 on Event2__e (after insert) {
  TriggerUtil.handleEvent(Trigger.new);
}

The class itself would just accept a generic list of records:

public class TriggerUtil {
  public static void handleEvent(sObject[] events) {
    // Do stuff here //
  }
}
1
  • Thank you sfdcfox! As usual, very helpful.
    – Adamo
    Commented Feb 21, 2020 at 13:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .