I want one Flow to do multiple things and wait at particular “gates” until an external website has updated Salesforce.
The website needs the data in a particular order.
The website can take a bit of time. We don’t want the users waiting around refreshing the page to see if the website has been updated.
But sometimes the website errors so we don’t want them to just set and forget - we want them to be alerted success or failure when the website finishes.
I also want it in one flow so the flow is easier to maintain, and has the logic built in - sometimes one pause will happen, sometimes three. So it’s going to go the quickest path possible.
I have a batch process that runs in bulk to bulk update records created that day. The batch process takes a few seconds per record. There is another batch process that runs later that day to do more calculations dependent on the calculation of that first batch.
When I want to just run the batch process on one record, I have to run it, wait for the first batch to complete, refresh the page, then wait for the second batch to complete and refresh. Again, if we had Live Records the page would refresh for me when the batch process completed.
But if I created a flow with a Wait element and triggered the PE to be created when the field is updated the first batch process completing, then I could automatically run the second batch process, and both calculations would be updated with the click of a button.
In my demo I had a few rogue Paused Flow Interviews…
There is a “bug” in Salesforce that Support won’t raise as a Known Issue and won’t include in the Documentation. If you have a heap* of Paused Flow Interviews still open, then Platform Events won’t fire. Yep, bizarre! I did a full video trying to explain the issue https://www.youtube.com/watch?v=gurBi3n6v20 and now that I review the video I can’t see there is a heap of Paused Flow Interviews hanging around so it’s making a liar out of me! Definitely raise a support ticket if you get stuck with any of this. * unknown how many but I had hundreds due to a logic error in my Flow that was not resuming from the last pause.
Note: I would NEVER use Paused Flow Interviews for actual waiting… Eg where Time Based Workflows work really well and you can see how many are waiting and you can know exactly which record the Flow is waiting on. Paused Flow Interviews are just a bit useless still.
No Pause in Screen Flows or Record Triggered Flows
You can only do Pause in Autolaunched Flows, not Screen Flows. But I want to kick my process off with a Screen Flow. So I start a screen flow, then call a Subflow that has the Pause, but it has a pretty bad experience for the end user as the Screen Flow ends with this dialog that they then have to close.
It is better than having to send 3 different records over to the Website separately, but it’s still not a good experience. What I need to do is instead of calling a Subflow, I need to update the record at the end of the screen flow, which then triggers an Autolaunhced Flow via a Process Builder.
This utopia of getting rid of Process Builders is so very far from reality, isn’t it.
Notifications have some glaring issues
NOTE: Notifications ONLY work IF the user has cleared their notifications! If the user has more than 20 unread notifications and you don’t get “notified” at all.
So maybe do a Chatter Post instead. Do NOT do an email notification as that defeats the purpose of having Salesforce.
2. Replace Wait
In my real-world scenario, I have a heap of DLRS Roll Up Summaries that need to be calculated soon after the record is updated, but do not need to be within the same transaction as the update to the record.
Good for high touch records that may have a heap of other triggers going on - especially from Managed Packages, and a regular save then takes too long.
Things to Note
3. External System Updates
Because you may not want to expose the main object to the external system via the Integration User, or you may need to have a flow to run in System Context after the external user updates some key fields.
Things to Note
There are other ways to do this… this is just one option. Eg there is really no difference in creating a Platform Event than giving permissions to the Integration User onto the object that needs to be updated. But as they need Read access to Create, you will not want them to be able to Read all records so then you would have to set Sharing Rules also. So the Platform Event is a nice easy, safe way to provide the access. But depending on the amount of data to be updated it may be a lot of work to set it all up.
If you want to create a real “webhook” style endpoint that is publicly available then you need to expose that via an Apex Class, then give the Guest Site User access to that Class. It’s pretty straightforward, but the Guest Site User just can’t publish a Platform Event directly.
Because Screen Flow error messages are awful and tell the user nothing.
Because sometimes showing the underlying error message directly to the user may help them quickly fix the issue and move forward, without waiting for the Admin to get the email, interpret what they were doing, and then help the user.