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
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

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