-
Notifications
You must be signed in to change notification settings - Fork 519
PlatformEventRecipesTriggerHandler
pozil edited this page Oct 19, 2020
·
18 revisions
Demonstrates how to construct a trigger handler for platform events
This is an admittedly contrived example. The key to Platform Event's utility is their interoperabilty. This recipe demonstrate what happens when a Platform Event is committed. Platform Event Triggers fire regardless of how the event was created: - You can create these events either through Apex, low code tools - and external system integrations
Account acct = new Account(name = 'Awesome Events Ltd.');
insert acct;
Event_Recipes_Demo__e evt = new Event_Recipes_Demo__e(accountId__c = acct.id, title__c='Updated website', url__c = 'https://developer.salesforce.com');
Database.saveResults result = PlatformEventsRecipes.publishEvent(evt);
System.debug(result + [SELECT Name, Website FROM Account WHERE id = :acct.id]);