cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Gao
Level: Powered On

Re: Handling Exception after when an action fails in Flow

Hi,

 

How do you handle an exception of a request response action failure in flow into powerapps? 

@Mr-Dang-MSFT

 

 

Powerapps.PNGException.PNG

13 REPLIES 13
Power Apps Staff Mr-Dang-MSFT
Power Apps Staff

Re: Handling Exception after when an action fails in Flow

Hi @Gao, it looks like Table1 does not exist. The previous step did not output any data which is why Response had an error. You'll need to receive data for this to work. And even if you do not receive data, you still need to have the same JSON structure in your data.

Gao
Level: Powered On

Re: Handling Exception after when an action fails in Flow

@Mr-Dang-MSFTThanks for the reply, I'm sorry for not being too descriptive. Yes I am aware that table1 doesn't exist. Question is how do you catch the error from flow into powerapps by not outputting the json error string into  powerapps. more in terms of explicitly displaying a user friendly response back stating for example "you have no records".

Power Apps Staff Mr-Dang-MSFT
Power Apps Staff

Re: Handling Exception after when an action fails in Flow

@KroonOfficeSol may have an answer here as well.

 

  1. I check if the results are not empty. I explicitly did this in a compose action, but you can forego it and directly do it in a condition.
  2. I create a condition: if the results are not empty, send the regular response.
  3. Otherwise, do another set of actions. In the example below, I simply used the same response schema, but with a blank body. Feel free to do any other actions of your choice.
    Screenshot (314).png
  4. In PowerApps, the blank response will result in a default error that says something to the effect that there was no response. 

  5. If you want to customize the error to say something different, you can use Notify(). Below I'm using similar logic to the flow, "If the collection is empty, communicate a warning to the user that no records were returned."{40CDC7D4-CA77-49C6-9405-725903A5D653}.png.jpg

     

 

KroonOfficeSol
Level 10

Re: Handling Exception after when an action fails in Flow

@Gao

 

The answer is fairly simple, you just have to insure there is a record returned from your stored procedure. You can do this by adding an UNION ALL SELECT statement to your Select query, returning a row with only NULLS.  Null should be matching the columns in the select statement.

 

Basically Flow gets at least one record and so has the schema and the result to return, so the error won't occur.

 

Then in PowerApps you remove the last row with this formula.

ClearCollect(YourCollection, YourFlow.Run())
;Remove(YourCollection, Last(YourCollection))

Leaving an empty well structured collection, when you don't have records returned.

 

 

Made a video on this topic, see Learn PowerApps | 22 | PowerApps - Flow - SQL Server - import Dynamic Data

 

 

Btw:  You just have to use three components: PowerApps, SQL, Request.

A nice trick for when the ResultSet.Table1 is not in your dynamic options for the request is to:

  • go to the custom editor
  • put in a letter
  • go back to the dynamic results
  • Pick the ResultSet
  • go back and delete the letter
  • add ?['Table1']


Hope this helps,

Paul

 

Gao
Level: Powered On

Re: Handling Exception after when an action fails in Flow

@Mr-Dang-MSFT Thanks, The solution you've proposed works on my local machine but as soon as I publish the app the problem still persists on the published site

KroonOfficeSol
Level 10

Re: Handling Exception after when an action fails in Flow

This is because the clearcollect() gives an error.
Gao
Level: Powered On

Re: Handling Exception after when an action fails in Flow

@Mr-Dang-MSFT Thanks, The solution you've proposed works on my local machine but as soon as I publish the app the problem still persists on the published site

Gao
Level: Powered On

Re: Handling Exception after when an action fails in Flow

@KroonOfficeSol Paul, thanks alot for the solution I have implemented what you've said regarding putting ResultSet.Table1 on the second request together. It works on the published site as well now. @Mr-Dang-MSFT

KroonOfficeSol
Level 10

Re: Handling Exception after when an action fails in Flow

@Gao

 

Again, lose the condition, this is unnecessary. Only three steps are required, see pic.

 

2019-02-07 16_38_25-Edit your flow _ Microsoft Flow.png

Helpful resources

Announcements
thirdimage

Power Apps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

SecondImage

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Top Kudoed Authors (Last 30 Days)
Users online (4,176)