Power Automate’s Send an email Not Seeing Variables

Software Bug

I’ve been doing some more work in flow for a client recently and hit, what I perceive as a serious bug.

The General Idea

The project itself is very interesting and opens up a lot of possibilities!

We have a form on a website that people fill out and submit.  Then, I use Power Automate’s Flow to process the data and I use an Execute stored procedure (V2) to then input the data into a database.  Lastly, I use the returned response from the stored procedure back in flow to fire off an appropriate notification e-mail using the Send an email (V2) action.

The Bug

So what’s the issue exactly?

Well, I originally had my stored procedure returning 3 output variables: 1 string and 2 int.  I use the Initialize variable 2 action to create a variable for each returned output.

When I would test the Flow, I could clearly see the variables were populated properly, but for whatever reason, I could not see/access the 2 int variables in the Send an email (V2) action.

The Workaround(s)

Cast as a String Output

I tried all sorts of things, figuring it has to be something I was doing wrong, but eventually found that it I cast the stored procedure’s int outputs as varchar and the assigned them to string type variables in Flow, then suddenly they were accessible in the Send an email (V2) action.

At the same time that I was coming up with my own workaround, I also posted a question in the Power Automate forums:

where user abm provided 2 other workarounds and confirmed that this is a known issue.  Oye!

Update 2022-03-15

I decided to do some more testing with other Stored Procedure output variable types: bit, int, float, char, varchar and found out the issue is more widespread.  Basically, Flow only reliably displays string outputs.  All other types do not display in the Dynamic Content listing.

Workaround – Create an Expression

Stored Procedure Output Variables

Even though the output variables do not appear in the Dynamic content listing, the Power Automate team informed me that they were still there and available to be used.  Of course, you need to know how!

You can actually build an Expression that uses the outputs() like:

outputs('YourActionName')?['body/outputparameters/YourOutputVariableName']

After recently testing, a concrete example of my usage was:

outputs('Execute_stored_procedure_(V2)')?['body/outputparameters/outputStatus']

Since this allows us to keep our Stored Procedures using their proper types, I believe this to be the preferable workaround by far.

Variables

In my flow, I also used the Initilize variable action and found that the Send and email action suffered from the same issue with variables as well.  To say this is unempressive would be the understatement of the year!

Luckily for us, we can do similarly to what we did for the Output variables and build our own expression to access them like:

variables('YourVariableName')

a concrete example could be

variables('delaySeconds')

Final Words on the Subject

So it would seem the issue with the Dynamic content not display elements is quite widespread.  Luckily there seem to be workarounds that work, problem being you need to be aware of the issue and the workarounds!  That wasn’t the case for me yesterday and I spent hours thinking I was doing things wrong when in fact the issue entirely lies on Microsoft’s shoulders.

I do have some good news on the subject to end with.  I emailed the Power Automate dev team about this and first and foremost, they were very responsive.  Secondly, they indicated they would be looking into the matter, so there may be a fix coming in the future.  Fingers crossed as it would truly bring the Dynamic content dialog to where it should be, functional!  🙂

One response on “Power Automate’s Send an email Not Seeing Variables

  1. John F Clark

    Thanks Daniel. I really appreciate it when you venture out of Access and incorporate other apps like your PowerShell wrapper and now Power Automate. If you are taking requests, Access intergration with the Power Platform is my vote!