Canceling Related Notifications With Flow
This guide explains the purpose and functionality of the 'Find and Close Notification Message' flow action and provides step-by-step instructions for administrators on how to use it effectively.
Overview
The Find and Close Notification Message action enables administrators to automate the closure of open notification messages (Sent Messages) in your Salesforce environment. This feature is designed for use with Salesforce Flow. Its purpose is to allow administrators to automatically remove notifications when they are no longer relevant, keeping the inbox focused on relevant and actionable items.
What Does It Do?
The feature allows admins to close open notification messages based on specific criteria, including:
- Related Record ID: Messages linked to a particular record.
- User Record ID: Messages associated with a specific user.
- Message Type Developer Name: Messages of a specific type.
At least one of these three inputs must be specified to identify messages. Only open messages matching all specified criteria will be closed.
How to Use It
1. Add the Feature to a Salesforce Flow
To use this functionality, follow these steps:
- Open Flow Builder:
- Navigate to Setup > Flows and create or edit a flow.
- Add an Apex Action:
- Drag the Action element into your flow.
- Search for and select the action labeled Find and Close Notification Message.
- Configure Inputs:
- Specify the input criteria for the messages to close:
- Related Record ID: Provide the record ID (optional).
- User Record ID: Provide the user ID (optional).
- Message Type Developer Name: Provide the developer name of the message type (optional).
- Reason for Closure: Provide a reason for closure (optional). This information will be added to the Sent Message record for auditing and troubleshooting purposes.
- At least one of the first three inputs must be specified to identify messages.
- Only open messages matching all specified criteria will be closed.
- Specify the input criteria for the messages to close:
- Handle Outputs:
- Capture the outputs of the action to understand the results:
- isSuccess: Indicates whether the operation was successful.
- errorMessage: Provides details in case of errors.
- closedMessages: A list of messages that were successfully closed.
- Capture the outputs of the action to understand the results:

Above is an example of a flow that executes when a Case's status is changed to 'Closed'. By passing the Case Id into the 'relatedRecordId' input AND ommitting any other inputs, we're instructing the action to close down ALL open notifications associated with the Case Record. If we passed in a 'userRecordId', the action would close notifications associated with both the record and the specified user (only).
Setting 'reasonForClosure' to 'Case is closed' will make it easy to identify why a message has been closed for reporting and troubleshooting purposes.
2. Monitor Results
- After running the flow, review the output fields to verify whether messages were successfully closed.
- If
isSuccess
isfalse
, check theerrorMessage
output for details.
3. Best Practices
- Validate Inputs: Ensure at least one of the required input fields is provided (Related Record ID, User Record ID, or Message Type Developer Name).
- Bulk Operations: When processing multiple requests, this feature handles bulk updates efficiently, ensuring scalability.
- Error Logging: Any errors encountered during processing will be logged to Salesforce debug logs for easy troubleshooting.
Use Cases
Here are some practical examples of how you might use this feature:
- Close Notifications for a Specific Record:
- Input the Related Record ID to close all messages associated with that record.
- Close Notifications for a Specific User:
- Input the User Record ID to close all messages owned by a particular user.
- Close Notifications of a Specific Type:
- Input the Message Type Developer Name to close all messages of a certain type.
- Close All Open Notifications of a Given Type for a Given Record:
- Input both the Related Record ID and the Message Type Developer Name to close all messages of the specified type associated with the specified record.
- Audit and Troubleshooting:
- Use the optional Reason for Closure field to document why the messages were closed.
Frequently Asked Questions (FAQs)
Q1: What happens if no messages match the criteria?
The action will return isSuccess = true
with an empty list of closedMessages
. This indicates that no matching messages were found to close, but the operation itself was successful.
Q2: Can I use multiple criteria at once?
Yes, you can specify multiple criteria (e.g., Related Record ID and User Record ID) to narrow down the messages to close. Only messages matching all specified criteria will be closed.
Q3: Will the newly closed messages disappear from view in the inbox?
Yes, the open messages should disappear from view after a few seconds (depending on your org's configuration).
Q4: What happens if an error occurs during the update?
If an error occurs, the action continues processing other messages and logs the error for the failed records. The isSuccess
field in the response will be false
for requests that encountered errors.
Q5: Can this feature be used outside of Flows?
This feature is designed primarily for use in Salesforce Flows but can also be invoked programmatically via Apex.
Summary
The Close Notification Messages action is a helpful tool for managing notification messages efficiently. By integrating it into Salesforce Flows, administrators can automate the closure of messages based on flexible criteria, ensuring accurate and efficient operations while keeping the inbox focused on actionable items.