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

Patch() with Errors() - error handling

I am adding a new record to my SharePoint List:

 

Patch(MyCustomList, Defaults(MyCustomList), { Title: "CustomTitle" });

 

How can I be sure that this record has been / will be successfully added to my list?

 

My thought so far:

  • Use before (or after?) Patch(): !IsEmpty( Errors( MyCustomList, Defaults(MyCustomList) ) )
  • After Patch(): get last record from the list and check if this is record I intended to add
2 REPLIES 2
Super User
Super User

Re: Patch() with Errors() - error handling

You use the Patch() in a variable and then test the variable to see if a record is created and it if has an ID.

 

Example of setting a variable using the results from Patch() :

Set(gvNewItem, Patch(PowerAppsDemo, Defaults(PowerAppsDemo),{Title:"Test"}))


--------------------------------------------------------------------------------
If this post helps answer your question, please click on “Accept as Solution” to help other members find it more quickly. If you thought this post was helpful, please give it a Thumbs Up.
Highlighted
Community Support
Community Support

Re: Patch() with Errors() - error handling

Hi @sch,

 

What @Jeff_Thorpe suggested works, and you could add a Label, set its Text property to:

gvNewItem.ID

You could check if the ID number in this Label control is changed after you run the Patch to make sure that the new record is added.

 

Regards,

Mona

Community Support Team _ Mona Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
August 2020 Community Challenge: Can You Solve These?

August 2020 Community Challenge: Can You Solve These?

We're excited to announce our first cross-community 'Can You Solve These?' challenge!

secondImage

Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

secondImage

Super Users Coming in August

We are excited for the next Super User season.

secondImage

Community User Group Member Badges

FIll out a quick form to claim your community user group member badge today!

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (6,992)