It seems like a no-brainer question with a simple “no” answer; however, there was something that came up on Linkedin while discussing my other post about using CDS pre/post images with the Flow:
What if, instead of using the service bus, we tried using “web hook” option in the Plugin Registration Tool? It does support synchronous execution, after all:
The url below will provide all the details on how to use that option, so I won’t be repeating the steps here:
Instead, I’ll jump right to the part where it did not work out the way I hoped it would with the Flows.
I did not have any problems registering a synchronous step in the pre/post operation:
And the Flow itself is relatively straightforward:
The flow will get the request,it will find record guid in the incoming json payload, and it will use that guid to update account phone #.
However, as it turned out, even though the Flow will be called synchronously, CDS “execution pipeline” won’t wait for the Flow completion. So, even though there were a few occurrences when I could see updated phone # right away while testing, most of the times I had to use “refresh” to see the change:
This makes sense after all, since it may take a while for the Flow to finish (not even talking about possible “delay” actions in the Flow), so, it seems, it’s only the initial trigger that will be called synchronously. The rest of the flow will still run a-synchronously from the execution pipeline standpoint.
Long story short… this is definitely yet another option for passing pre/post images to the Flow, but it does not seem to help with the synchronous execution. Yet it’s probably not as scalable as the service bus. Although, unlike with the service bus approach, there are less steps involved here, so this may get the job done a little faster.
Update (as of June 30): this post attracted the likes of George Doubinski (see comments below), so I stand corrected:) See this: https://www.itaintboring.com/dynamics-crm/can-we-call-a-microsoft-flow-synchronously-on-createupdate-of-a-record/
Or, well, I kind of stand corrected. By the way, also wanted to give credit to Shidin Harridas who was likely the first to suggest using the response action.
It seems the question posted in the subject can have different answers depending on what we need that synchronous flow to do.
- We can call the Flow synchronously
- If there is no response action, the web hook won’t wait for the Flow completion, so your CDS operation may complete before the Flow has completed
- If there is a response action, and if your Flow tries to update the same record BEFORE getting to the response action, then the whole process will fail
The last scenario represents about 80% of my use cases for the synchronous plugins/real-time workflows, so the answer to the question might still be “no” with caveats.
So… why does the Flow fail in this scenario? It sounds reasonable there is some kind of deadlock, but it can’t be a database transaction deadlock, since the same Flow also fails when the webhook registration has been updated to run in “Pre Validation”, which is supposed to run before the transaction starts (https://docs.microsoft.com/en-us/powerapps/developer/common-data-service/event-framework) Unless it’s not the case for the web hooks?