Canceling Select Notifications With Flow
This guide introduces the Cancel Selected Notifications with Flow action. This action provides a direct way for Flow builders to close specific notification messages by explicitly selecting which ones to close in the Flow itself.
Overview
The Close Message List action enables administrators to automate the closure of open notification messages (Sent Messages) by passing in a selected list of messages. Unlike the Find and Close Notification Message action, which dynamically searches for matching messages, this version puts full control in the hands of the Flow builder — you specify exactly which messages should be closed.
What Does It Do?
This action allows admins to close a list of selected notification messages. It's perfect for advanced Flow use cases where the messages to be closed are already known or have been identified earlier in the Flow logic.
The action performs the following:
- Re-checks that each provided message is still open.
- Closes valid open messages by:
- Setting
IsClosed
andIsAutoClosed
to true. - Stamping the closure time.
- Recording an optional reason for closure.
- Setting
- Skips any already closed messages.
- Returns the list of successfully closed messages and any relevant messages or errors.
How to Use It
1. Add the Feature to a Flow
Steps:
- Open Flow Builder:
Go to Setup > Flows, then create or edit a Flow. - Query or Collect Messages to Close:
Use a Get Records element or other logic to identify the messages you want to close. These must beActOnIt__MessageRecipient__c
records. - Add the Apex Action:
Drag an Action element into your Flow.- Search for the action labeled: Close Notification Messages.
- Configure the Inputs:
- messagesToClose (required): Pass in the list of message records to close.
- reasonForClosure (optional): Include a reason for closing the messages (for audit and troubleshooting).
- Handle the Outputs:
isSuccess
: Indicates if the closure operation was successful.errorMessage
: Explains any problems that occurred.closedMessages
: A list of messages that were successfully closed.
Example Flow
Suppose you're creating a flow that sends and manages onboarding notifications. If a user completes onboarding early, you may want to cancel the remaining messages.
You could:
- Use a Get Records element to find all onboarding messages for that user.
- Use a Filter or Decision element to narrow them down.
- Pass the result into Close Notification Messages.
This gives you full control — only the messages you select will be closed.
2. Monitor Results
After running the flow, inspect the output fields to confirm the operation:
- If
isSuccess = true
andclosedMessages
contains records, the action succeeded. - If
errorMessage
is populated, review it to understand what went wrong.
3. Best Practices
- ✅ Include a Reason for Closure when possible — this helps with tracking and auditing.
- ✅ Combine with Flow filters or logic to tightly control which messages should be closed.
- 🚫 Avoid passing in empty or null lists — this will return a failure response.
Use Cases
Here are some example use cases for this action:
- Cancel messages after condition is met early: E.g. user completes onboarding or a task is marked “Not Needed.”
- Selective cleanup: Only close certain types of notifications for a user — e.g., reminders but not alerts.
- Admin Flow buttons: Let an admin run a Flow manually and choose which messages to cancel.
- Post-process: Use the action at the end of an automation that originally sent messages, to clean up ones no longer needed.
Frequently Asked Questions (FAQs)
Q1: Can I use this without Flows?
Yes — this Apex action can be called programmatically, but it's built primarily for Flow usage.
Q2: What happens if a message is already closed?
It will be skipped. The action only closes messages that are still open.
Q3: Do I need to specify a reason?
No — but it's highly recommended. The reason is stored on the message for auditing.
Q4: Will the messages disappear from inboxes immediately?
Yes — hidden and closed messages should be removed from the interface shortly after the update.
Q5: Will it throw errors if the list contains invalid messages?
Only valid messages (open + with an Id) are processed. Others are ignored. If an error occurs while updating, it's logged, and other messages continue processing.
Summary
The Close Provided Notification Messages action gives administrators fine-grained control to close notification messages directly within Salesforce Flows. Use it when you’ve already identified which messages to close and want to ensure precise, targeted cleanup of user inboxes.