cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Radek225
Frequent Visitor

Check if output of SQL Get rows is empty

Hi 

 

I'm wondering how can I check if output of Get rows action is empty. I tried to use this

 

outputs('Get_rows_(V2)_3')?['body/value'] is equal to empty(outputs('Get_rows_(V2)_3')?['body/value'])

 

but it doesn't work - it shows that array is not empty, but that is not true at least not this array I'm interested in. I think it's because after value there are other arrays like datasets, tables, items. But I don't know how to get there in expression

Here is raw output from my action

 

...,"body":{"@odata.context":"https://flow-apim-europe-002-northeurope-01.azure-apim.net/apim/sql/shared-sql-620272d2-6ce9-427b-871d-a7c69f7191da/$metadata#datasets('default%2Cdefault')/tables('%5Bdbo%5D.%5BSchedule%5D')/items","value":[]}}

 

Does anyone know how to refer to datasets=>tables=>items=>value in expression and use it in above mentioned empty function?

2 ACCEPTED SOLUTIONS

Accepted Solutions
ekarim2020
Super User
Super User

Hi @Radek225 

 

You can use the length function. If length = 0, then no items were returned by the Get rows action:

legnth(outputs('Get_rows_(V2)_3')?['body/value'])

 

ekarim2020_0-1662412430736.png


Ellis
____________________________________
If I have answered your question, please mark the post as Solved.
If you like my response, please give it a Thumbs Up.

View solution in original post

Radek225
Frequent Visitor

Ahh sorry now I realized this what I wrote didn't make sense

this is correct usage of empty function:

empty(outputs('Get_rows_(V2)_3')?['body/value']) is equal to true

 and that works:)

@ekarim2020 I checked also length and it works either:)

 

View solution in original post

3 REPLIES 3
ekarim2020
Super User
Super User

Hi @Radek225 

 

You can use the length function. If length = 0, then no items were returned by the Get rows action:

legnth(outputs('Get_rows_(V2)_3')?['body/value'])

 

ekarim2020_0-1662412430736.png


Ellis
____________________________________
If I have answered your question, please mark the post as Solved.
If you like my response, please give it a Thumbs Up.

mobashee
Community Support
Community Support

Dear Partner,

As suggested by Ellis, you can use length function, please refer to the below link for more detailed info

https://powerusers.microsoft.com/t5/Power-Automate-Community-Blog/Power-Automate-Fundamentals-50-Get...

 

 

Did I answer your question? Please consider to mark my post as a solution to help others.

 

Regards,

Mohamed Sanuj Basheer

Radek225
Frequent Visitor

Ahh sorry now I realized this what I wrote didn't make sense

this is correct usage of empty function:

empty(outputs('Get_rows_(V2)_3')?['body/value']) is equal to true

 and that works:)

@ekarim2020 I checked also length and it works either:)

 

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Users online (1,969)