cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
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
Highlighted
Super User II
Super User II

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

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
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Community Highlights

Community Highlights

Check out the Power Platform Community Highlights

Top Solution Authors
Top Kudoed Authors
Users online (7,798)