cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
alex93jansen
Helper II
Helper II

Access output from Execute a SQL Query (V2)

I'm aware this question has been asked several times, but it seems the functionality of this item has changed recently and none of the solutions people have suggested are working for me.

 

I have a Flow which is triggered through PowerApps, taking several input parameters (provided by PowerApps) to verify whether 1 or more records matching the parameters already exist in a SQL table.

 

Execute a SQL query (V2) action:

alex93jansen_3-1626141165925.png

Execute a SQL query (V2) response:

alex93jansen_2-1626141081439.png

The issue is that there's no way for me to access the "count" variable in this response. I have tried the "Compose" and "Parse JSON" actions, but neither allow me to input the SQL response body anywhere.

 

 

3 REPLIES 3
eric-cheng
Solution Sage
Solution Sage

Hi @alex93jansen ,

 

Because Table1 is a JSON array, it will try to loop the JSON objects within. 

 

I will provide two options:

 

Option 1 

 

ericcheng_1-1626155978703.png

Add a Parse JSON underneath and copy the above Body into the sample JSON payload

ericcheng_2-1626156279825.png

 

Add a Compose action underneath and go to expressions and paste this in (you may need to tweak Parse_JSON depending on the name of the action in the previous step).  What this does is to return the first JSON object in the index and count field.

 

body('Parse_JSON')?['ResultSets']?['Table1'][0]['count']
 

ericcheng_3-1626156294637.png

 

When you run it, it should return the count

ericcheng_4-1626156429369.png

 

Option 2 

 

You could also try the Get rows (v2) action which will still allow you to apply filters.  You can then get the length of the value to get the row count.

 

length(body('Get_rows_(V2)')?['value'])
 
ericcheng_0-1626155573095.png

 

--------------------------------------------------------------------------
If I have answered your question, please mark my post as a solution
If you have found my response helpful, please give it a thumbs up

 

Thanks for the reply.

 

I tried Option 1, as follows:

alex93jansen_0-1626197287352.png

which creates the "Schema" in the Parse JSON action. However, for the "Content" I'm not able to put any Dynamic Content from the SQL query action (only PowerApps items show up):

alex93jansen_1-1626197369107.png

 

I also tried Option 2 which does work, so I got everything work the way it should now. Thanks.

Glad its sorted

 

--------------------------------------------------------------------------
If I have answered your question, please mark my post as a solution
If you have found my response helpful, please give it a thumbs up

Helpful resources

Announcements
Power Automate News & Announcements

Power Automate News & Announcements

Keep up to date with current events and community announcements in the Power Automate community.

Community Calls Conversations

Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Automate Community Blog

Power Automate Community Blog

Check out the latest Community Blog from the community!

Users online (4,021)