Salesforce Platform Events
Salesforce Platform Events is an event-driven messaging architecture enabling apps to communicate inside and outside of Salesforce. Events allow you to define custom data models (events) using Salesforce Object Query Language (SOQL) that suit your specific business needs. These events are essentially custom objects in Salesforce. Platform Events can trigger processes, workflows, Apex triggers, or external systems. For example, you can use a Platform Event to trigger a Flow or invoke an Apex class when a specific event occurs.
Platform event can be used to communicate when a Dynamo API task has been completed. The event can contain task ID to connect it with Task API post request.
Creating platform events
Since it’s the same as a custom object, if one is not yet created, the following steps can be used to create Platform Events. Otherwise, an existing Platform Events can be used with new custom fields:
Create a custom platform event by going to Salesforce Settings > Platform Events > New Platform Event
Give it an object Name, such ad ‘Dynamo Event’ (The suffix '
__e
' will be added automatically to the given object nameCreate custom fields to hold post task values
After a custom platform event has been defined in Salesforce, it is ready to be used in DAP logic. A platform event can be created with
create
command in the Flow. For example, if API template is used, the commands can be put in Exit step (in Exit Segment) so that a new Platform Event record will be created whenever the template flow is done
create type=Dynamo_Event__e
field name=TaskID__c value=${dynamoAPI.taskID}
field name=Error value=${error}
In the above example, the custom platform event has the TaskID (TaskID__c
) and Error (Error
) custom fields.
TaskID field is used to store Dynamo API task ID, which is also returned when posting the task through Dynamo API.
The Error field is used to report any errors. The Error variable is empty if no error occurred during the DAP run.
Custom events can be extended with custom fields to return required data from template logic, such as: created document’s ContentDocumentID, completed date, or any other values created within the template flow to communicate with Salesforce to trigger Salesforce Flow, etc.
Platform event triggered flow
Platform events triggered flow launches when a platform event message is received. This flow type can be used to handle Dynamo API task events.