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

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

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

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

secondImage

Demo Extravaganza Winner Announcement

Please join us on Wednesday, July 21st at 8a PDT. We will be announcing the Winners of the Demo Extravaganza!

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Top Solution Authors
Top Kudoed Authors
Users online (2,535)