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

Patch function in Excel saving multiple copies of the same data

I've used a Patch to Excel in a similar way in another app and had no issues but for some reason in this ticket management app, whenever I Patch my data, my gallery and table keep saving multiple copies of the same data even though I only pressed the button once. 

 

Screenshot (41).png

 

I feel like it may be tied to the "ForAll' part but I'm not sure. Please help!

1 ACCEPTED SOLUTION

Accepted Solutions
Drrickryp
Super User
Super User

Hi @dsanf19 

You have got that right.  ForAll() loops though a collection of multiple items and adds every record as a new record.  If you are simply trying to add a single record like the data in the form on the left side of the gallery, all you need is a  patch with the names of the the fields and the control containing the data.  Something like: 

Patch(datasource, Defaults(datasource), {field1: TextInput1.Text, field2: Dropdown1.Selected.Value, etc.})

In a Patch(), The first element is the datasource or collection being patched, the second element, "Defaults()", indicates that a new record is being created.  Third, the fields indicated inside the curly braces are populated with the values in the controls.  

View solution in original post

1 REPLY 1
Drrickryp
Super User
Super User

Hi @dsanf19 

You have got that right.  ForAll() loops though a collection of multiple items and adds every record as a new record.  If you are simply trying to add a single record like the data in the form on the left side of the gallery, all you need is a  patch with the names of the the fields and the control containing the data.  Something like: 

Patch(datasource, Defaults(datasource), {field1: TextInput1.Text, field2: Dropdown1.Selected.Value, etc.})

In a Patch(), The first element is the datasource or collection being patched, the second element, "Defaults()", indicates that a new record is being created.  Third, the fields indicated inside the curly braces are populated with the values in the controls.  

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Difinity Conference 2022

Difinity Conference 2022

Register today for two amazing days of learning, featuring intensive learning sessions across multiple tracks, led by engaging and dynamic experts.

European SharePoint Conference

European SharePoint Conference

The European SharePoint Conference returns live and in-person November 28-December 1 with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.

Power Apps Ideas

Check out the New Ideas Site

We are excited to announce a new way to share your ideas for Power Apps!

Top Solution Authors
Top Kudoed Authors
Users online (3,028)