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
Super User
Super User

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

Community Blog

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

Power Apps Community Call

Power Apps Community Call- January

Mark your calendars and join us for the next Power Apps Community Call on January 20th, 8a PST

PP Bootcamp Carousel

Global Power Platform Bootcamp

Dive into the Power Platform stack with hands-on sessions and labs, virtually delivered to you by experts and community leaders.

secondImage

Power Platform Community Conference On Demand

Watch Nick Doelman's session from the 2020 Power Platform Community Conference on demand!

Top Solution Authors
Top Kudoed Authors
Users online (4,318)