-
Notifications
You must be signed in to change notification settings - Fork 460
PlatformEventRecipes
pozil edited this page Nov 14, 2024
·
16 revisions
Demonstrates how to publish events on the event bus
Group Platform Event Recipes
See PlatformEventRecipesTriggerHandler
See PlatformEventPublishCallback
publishes a platform event
public static Database.SaveResult publishEvent(Event_Recipes_Demo__e event)
Name | Type | Description |
---|---|---|
event | Event_Recipes_Demo__e | an Event_Recipes_Demo__e object |
Database.SaveResult
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);
publishes a platform event and handles success/failure with callbacks
public static Database.SaveResult publishEventWithCallbacks(Event_Recipes_Demo__e event)
Name | Type | Description |
---|---|---|
event | Event_Recipes_Demo__e | an Event_Recipes_Demo__e object |
Database.SaveResult
Account acct = new Account(Name = 'Awesome Events Ltd.');
insert acct;
// Creating the event via sObjectType.newSObject is required to obtain an EventUuid
Event_Recipes_Demo__e event = (Event_Recipes_Demo__e) Event_Recipes_Demo__e.sObjectType.newSObject(null, true);
event.AccountId__c = acct.Id;
event.Title__c = 'Updated website';
event.Url__c = 'https://developer.salesforce.com';
PlatformEventRecipes.publishEventWithCallbacks(event);
Internal custom exception class