cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
koperek7
Regular Visitor

How to handle empty response?

Hi,


I’m having a problem with canvas application.

In my App, I have a filter panel, so user is able to filter everything what they want. Then ‘Search’ button invokes power automate flow, execute SQL stored procedure, and output data are send back to Power Apps - that it’s fine.

The output is displayed in a power apps gallery. Everything works fine as long as the returned result is not empty. It’s not an issue when output is empty, it just means that no records in sql were found for selected criteria.

Once the output is empty, Then the problem starts with my gallery and the fields that are referring or expecting always non-empty values.

As you can see on the attached window, there is a Red Cross icon next to my fields in a gallery, which display values that should come within output?

 

the question is how to handle empty responses in a gallery, and avoid showing it as an error or something??

the error message I got is: “MyFlow.Run failed: the data returned in the response is invalid. Response data should be a valid JSON object”

 

just to remind you, it happens only when the called procedure returns empty results.

When I Call a procedure with a data which exists in a database, then of course everything is fine with the output and the gallery which displays it.

 


Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
v-bofeng-msft
Community Support
Community Support

Hi @koperek7 :

The point is that an error occurs when the response's body is null. So you can first set a judgment condition, when the value of the target parameter is null, use an empty array instead . For example:

vbofengmsft_0-1643001755742.png

if(
  equals(outputs('Compose_2'),null),
  json('[]'),
  outputs('Compose_2')
)

On your side , you could replace outputs('Compose_2') with the return value of 'executing the stored procedure' action.

Best Regards,

Bof

 

View solution in original post

1 REPLY 1
v-bofeng-msft
Community Support
Community Support

Hi @koperek7 :

The point is that an error occurs when the response's body is null. So you can first set a judgment condition, when the value of the target parameter is null, use an empty array instead . For example:

vbofengmsft_0-1643001755742.png

if(
  equals(outputs('Compose_2'),null),
  json('[]'),
  outputs('Compose_2')
)

On your side , you could replace outputs('Compose_2') with the return value of 'executing the stored procedure' action.

Best Regards,

Bof

 

Helpful resources

Announcements
October Events

Mark Your Calendars

So many events that are happening this month - don't miss out!

Ignite 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Top Solution Authors
Top Kudoed Authors
Users online (2,091)