I got a tricky Power Automate Flow the other day – it was boldly refusing to meet my expectations in what it was supposed to do. In retrospect, as much as I would want to say that it was all happening since Power Automate was in a bad mood, there seem to be a couple of things we should keep in mind when creating the Flows, and, somewhat specifically, when using Common Data Service(current environment) connector:
That connectors supports FetchXml queries in the List Records action, which makes it very convenient in the situations where you need to query data based on some conditions.
Here is what may happen, though.
Let’s imagine some simple scenario for the Flow:
- The Flow will start on create of the lead record
- When a lead is created, the Flow would use “List records” action to select a contact with the specific last name
- Finally, the flow would send an email to that contact
And there will be two environments, so the idea is that we’ll use a managed solution to move this flow from development to production:
Let’s see if it works? I’ve created a lead, and here is my email notification:
But wait, wasn’t it supposed to greet me by name, not just say “Hello”?
Problem is, even though I can use all those attributes in the flow, they have to be added to the FetchXml in order to query them through the List Records action. Since I did not have firstname included in the Fetch, it came up empty.
The fix is simple:
And I have my email with the proper name now:
Now let’s bring this flow through a managed solution to another environment.
- Export as managed
- Import into the prod environment
Before I continue, let’s look at the solution layers for that flow in production:
Everything is perfect, but now we need to fix the connections for the flow:
- Once the connections have been fixed, apparently we need to save the Flow.
- What happens to the solution layers when we click “save”, though?
That is, actually, unfortunate. Let’s say I need to update the Flow now.
In the development environment, I can add an extra attribute to the Fetch:
That solution is, then, exported with a higher version, and I’m about to bring it over to production:
I should see that attribute added in production now, right?
You can see it’s not there.
I would guess this problem is related to the solution layering – when updating connections in production, I had to save the flow there, and that created a change in the unmanaged layer. Importing updated managed solution made changes to the managed layer, but, since it was an existing solution/flow, those changes went just under the unmanaged layer, so they did not show up on the “surface”.
If I go to the solution layers for my flow in product and remove active customizations:
All connections in the Flow will be broken again, but that additional attribute will finally show up:
This is when I can fix the connections, and, finally, get the Flow up and running as expected.
Of course another option might be to remove managed solution completely and to re-import updated version. Since I normally have Flows/Workflows in a separate solution, that would probably work just fine, even if I had to request a downtime window.