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

Powerapps-error handling in code block

Hi,
Good Day! I'm here to ask a query, what's going wrong inside my code. if there is any exception or error that comes in the code block, it should log that exception or error in my database(excel).

Following are the attached images or screenshots of the code.

xc0_0-1616134328970.png

here, it's patching the data concurrently in the database and if there is any error comes within that code block, it should log the error, for that after concurrent ends, I've given a patch statement to log the error in the third table, but if there is not an error, it is leaving an empty entry in the database, please help me to get this sorted.

4 REPLIES 4
v-bofeng-msft
Community Support
Community Support

Hi @xc0 :

Please try this formula:

IfError(
   Concurrent(
     Patch(Product_info,Defaults(Product_info),{TheRecord}),
     Patch(Table1,Defaults(Table1),{TheRecord})
 ),
 If(!IsBlank(First(Errors(Product_info)).Message),Patch(Table9,Defaults(Table9),{TheRecord}));
 If(!IsBlank(First(Errors(Table1)).Message),Patch(Table9,Defaults(Table9),{TheRecord}));
 Notify("Data is not saved for " & IF(!IsBlank(First(Errors(Product_info)).Message),"Product_info",!IsBlank(First(Errors(Table1)).Message),"Table1","Product_info & Table1")),
 Notify("Success")
)

Best Regards,

Bof

xc0
Regular Visitor

hi Bof,

yes, you are right! Thanks for the early response!
I have tried like this already, but I wanted to do it for multiple tables at that time, the above solution is lengthy and also i have to write the condition of if for multiple tables. So, cant we do like, if I got an error in concurrent block so that we can handle that block that contains errors from multiple tables at once. if its possible please reply,

Thanks,

Ashvini Mungal

 

hi@v-bofeng-msft ,

yes, you are right! Thanks for the early response!
I have tried like this already, but I wanted to do it for multiple tables at that time, the above solution is lengthy and also i have to write the condition of if for multiple tables. So, cant we do like, if I got an error in concurrent block so that we can handle that block that contains errors from multiple tables at once. if its possible please reply,

Thanks,

XC0

v-bofeng-msft
Community Support
Community Support

Hi @xc0 :

Maybe you could try this formula:

IfError(
   Concurrent(
     Patch(Product_info,Defaults(Product_info),{TheRecord}),
     Patch(Table1,Defaults(Table1),{TheRecord})
 ),
 ClearCollect(MyCollection,{errormsg:First(Errors(Product_info)).Message});
 Collect(MyCollection,{errormsg:First(Errors(Table1)).Message});
 Collect(Table9,Filter(MyCollection,!IsBlank(errormsg)));
 Notify("Data is not saved"),
 Notify("Success")
)

Best Regards,

Bof

Helpful resources

Announcements
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.

Super User 2 - 2022 Congratulations

Welcome Super Users

The Super User program for 2022 - Season 2 has kicked off!

September Events 2022

Check out all of these events

Attend in person or online, there are incredible conferences and events happening all throughout the month of September.

Users online (4,534)