How do we generate a toast message while clicking on a action button where we will be calling the flow.How can we do that using auto launch flows?
(Non-trigger) auto-launch flows have no ability to present messages since they run in a "headless context" - as the documentation says, they run in the background and are asynchronous. You can initiate them from all sorts of places:
- Through the UI
- By a standard or custom REST API
- By a scheduled job
- In async code
Only the first scenario would have any way to show something on the UI.
I could imagine writing a a custom LWC, e.g.
toaster, that polls (or uses the emp API to be notified of creation of) records of a specific type of object, e.g.
Toast__c, perhaps associated with the current User, and have this generate toasts from the records' details (deleting the records once the toast is shown). You could then have an auto-launch flow that, when the conditions are met, creates the required record(s) of this custom type
Toast__c, setting required properties as needed. As long as you include the custom
toaster LWC in your Salesforce UI pages you get toasts appearing from nowhere when the flow generates the records.
You might be able to apply something similar with platform events too.
NB: Trigger-based auto-launch flows also cannot present data for many of the same reasons.
I had a similar requirement. I used this package. It might help you too: https://unofficialsf.com/show-toast-flow-action/