web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Forall is creating mul...
Power Apps
Answered

Forall is creating multiple entries in Sharepoint

(0) ShareShare
ReportReport
Posted on by 76

Hello,

I created a Datasheet with 2 Sections. Both Sections have a Save Button:

 

Save Button 1:

 

Collect(OfflineOverviewCollection, 
{
 Bereich: BereichDropdown.SelectedText.Value,
 Unternehmen: UnternehmenInput.Text,
});
SaveData(OfflineOverviewCollection,"Offline")

 

 

SaveButton 2 has the entries of the second Section:

 

Collect(OfflineOverviewCollection, 
{
 Fahrzeughersteller: FahrzeugherstellerInput.Text,
 Fahrzeugtyp: FahrzeugtypDropdown.SelectedText.Value,
 Fahrzeugmodell: FahrzeugmodellInput.Text,
});
SaveData(OfflineOverviewCollection,"Offline")

 

The SaveData is an Offline Function, working with a LoadButton using

 

LoadData(OfflineOverviewCollection,"Offline")

 

 

The Code where i think is the Problem, an Upload Button with a ForAll/Patch Function, to upload it to a SharepointSite:

 

ForAll(OfflineOverviewCollection,
 Patch(OverviewList, Defaults(OverviewList) 
 ,{
 Bereich: Concat(OfflineOverviewCollection.Bereich, Bereich),
 Unternehmen: Concat(OfflineOverviewCollection.Unternehmen, Unternehmen),
 Fahrzeughersteller: Concat(OfflineOverviewCollection.Fahrzeughersteller, Fahrzeughersteller),
 Fahrzeugtyp: Concat(OfflineOverviewCollection.Ort, Ort),
 Fahrzeugmodell: Concat(OfflineOverviewCollection.Fahrzeugmodell, Fahrzeugmodell),
 }

)
)

 

 

 

I tried it out and first i got 2 entries when clicking on Both SaveButtons, then on Load Data and finally on Upload

I clicked on it again and since then im getting 4 entries everytime, just by clicking on Upload

 

I found an older "Solution" for the same problem, but i dont know how to use the code on my example:

https://powerusers.microsoft.com/t5/Building-Power-Apps/ForAll-is-creating-same-record-multiple-times-on-multi-select/td-p/1439292

 

Thanks for the Help!

Pascal

Categories:
I have the same question (0)
  • LuizVicente Profile Picture
    984 Super User 2024 Season 1 on at

    The duplicity is because you are increasing the collection on two occasions. I made a simulation with your code and look at the result of the collection:

     

    Roverandom_0-1660832290091.png

    Another weird thing I noticed is that there's a comma on the last line of every record. As far as I know Power Apps doesn't allow this, doesn't yours issue an alert/error about it?

     

    Roverandom_1-1660832510827.pngRoverandom_2-1660832541058.pngRoverandom_3-1660832574497.png

     

  • Polarus Profile Picture
    76 on at

    Hello,

    Ah okay. is there a roundabout?


    About the commas: I have a lot more entries with these "Fahrzeug: ...... ," 
    I simply cut them out to simplify the code for this forum.

  • Verified answer
    Ricardo_Costa Profile Picture
    150 on at

    you can not use collect in the second save button since you're trying to update the same previous record. So you need to collect in the first button and patch in the second.

    The key is that for the patch function you will need an unique ID to find the record and that ID must be available in the section 2. With the code below, you will not create two records but just one and then the forAll function will works.

     

    Save Button 1:

    Collect(OfflineOverviewCollection,
    {
    Bereich: BereichDropdown.SelectedText.Value,
    Unternehmen: UnternehmenInput.Text,
    Fahrzeughersteller: Blank(),
    Fahrzeugtyp: Blank(),
    Fahrzeugmodell: Blank()
    });

     

    Save Button 2:

    Patch(OfflineOverviewCollection, Lookup(OfflineOverviewCollection,ID = Sections.ID),
    {
    Fahrzeughersteller: FahrzeugherstellerInput.Text,
    Fahrzeugtyp: FahrzeugtypDropdown.SelectedText.Value,
    Fahrzeugmodell: FahrzeugmodellInput.Text
    });

     

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 531 Most Valuable Professional

#2
Haque Profile Picture

Haque 261

#3
Kalathiya Profile Picture

Kalathiya 221 Super User 2026 Season 1

Last 30 days Overall leaderboard