Subscribing to Trigger Events in a Flow
What Does Subscribing to Trigger Events Mean?
Subscribing to Trigger Broker Events in a flow allows admins to define business logic whenever a platform event is published. This eliminates the need for custom Apex and enables low-code automation.
Why Should You Use This?
- Low-Code Automation: Create powerful workflows without writing code.
- Flexibility: Respond dynamically to changes on unsupported objects.
- Scalability: Adjust flows as business needs evolve.
Example Use Case: Notify Case Owner of a File Attachment
This use case demonstrates how to notify the Case Owner when a file is attached to a case. Refer to the "Act On It - Notify Case Owner On File Attachment" Flow Template for reference.
Step-by-Step Guide
- Start a Flow with a Platform Event Trigger:
- Create a new Platform Event-Triggered Flow.
- Select the
TriggerBrokerEvent__e
platform event as the trigger.
- Add a Decision Element:
- Name: IsFileAttachmentEvent.
- Description: Checks if the event is for a new file attachment.
- Conditions:
SObjectType__c = "ContentDocumentLink"
TriggerEvent__c = "AFTER_INSERT"
- Add a Get Records Element:
- Name: Lookup Content Document Link.
- Description: Retrieves the
ContentDocumentLink
record usingTriggerRecordId__c
. - Query: Filter by
Id = {!TriggerRecordId__c}
.
- Add a Decision Element:
- Name: Determine Linked Record Type.
- Description: Checks if the file is attached to a Case (prefix
500
). - Condition:
LEFT({!LinkedEntityId}, 3) = "500"
.
- Add a Get Records Element:
- Name: Lookup Case Record.
- Description: Retrieves the Case record using
LinkedEntityId
.
- Add Another Decision Element:
- Name: Is Case Owner the Running User.
- Description: Skips notification if the Case Owner added the attachment.
- Condition:
{!OwnerId} != {!UserInfo.getUserId()}
.
- Add a Publish Message Action:
- Name: Notify Case Owner.
- Description: Sends a push notification to the Case Owner.
- Input: Record ID =
{!OwnerId}
.
Benefits
- Efficiency: Automate repetitive tasks without complex development.
- Customization: Tailor flows to fit specific business needs.
- Future-Proof: Add new triggers and flows as needed without disrupting existing processes.
With this setup, you can enhance automation capabilities while maintaining flexibility and scalability.