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
Highlighted
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
Ignite

Microsoft Ignite

This will be a conference that you do not want to miss!

secondImage

New Return to Workplace

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

August 2020 CYST Challenge

Check out the winners of the recent 'Can You Solve These?' community challenge!

Experience what’s next for Power Apps

Join us for an in-depth look at the new Power Apps features and capabilities at the free Microsoft Business Applications Launch Event.

Check this Out

Helpful information

Featuring samples like Return to the Workplace and Emergency Response Applications

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (5,054)