Skip to main content

Notifications

Community site session details

Community site session details

Session Id : WAnZUiDgcppmWEaBELYH+D
Power Apps - Building Power Apps
Answered

Gallery.AllItems with ForAll / Collect Question

Like (0) ShareShare
ReportReport
Posted on 2 Oct 2019 19:31:13 by

I'm having an issue with a Gallery and saving the items in the Gallery to a collection (or I'm just doing it wrong).  I load a Gallery and filter it based on user selected value. Here you can see there are 3 items in the gallery (confirmed by the count of Gallery.AllItems)

Gallery.png

The Save All button has the following code which is causing an issue:

//Create collection with modified equipment information
Clear(ModifiedCollection);

ForAll(EquipmentGallery_DetailsScreen.AllItems,
 Collect(ModifiedCollection, 
 {
 RequestID: EquipmentGallery_DetailsScreen.Selected.RequestID,
 ID: EquipmentGallery_DetailsScreen.Selected.ID,
 AssetID: EquipmentGallery_DetailsScreen.Selected.AssetIDTextboxInput_DetailsScreen.Text,
 VIN: EquipmentGallery_DetailsScreen.Selected.VINTextboxInput_DetailsScreen.Text,
 Vendor: EquipmentGallery_DetailsScreen.Selected.VendorTextboxInput_DetailsScreen.Text,
 IsPending: !(EquipmentGallery_DetailsScreen.Selected.IsPendingToggle_DetailsScreen.Value),
 FulfilledBy: If( !(EquipmentGallery_DetailsScreen.Selected.IsPendingToggle_DetailsScreen.Value) = false, varCurrentUser.Email),
 FulfilledDate: If( !(EquipmentGallery_DetailsScreen.Selected.IsPendingToggle_DetailsScreen.Value) = false, conDateTime),
 IsAssetIDAssigned: If(IsBlank(EquipmentGallery_DetailsScreen.Selected.AssetID), false, true)
 }
 )
);

I was expecting the ForAll to loop over all the items in the Gallery and add the field values to the collection.  However, this is what I get instead.  The first item in the Gallery added 3 times.

Collections.pngWhat am I doing wrong? How do I save the filtered items in the Gallery to a new collection? Thanks!

Categories:
  • MW Profile Picture
    Microsoft Employee on 08 Nov 2023 at 14:28:59
    Re: Gallery.AllItems with ForAll / Collect Question

    If you ran in the same issue, being unable to load all items in a Gallery, please vote and support this idea: Enable the option to load all items in a Gallery · Community (powerapps.com)

  • Verified answer
    Community Power Platform Member Profile Picture
    on 02 Oct 2019 at 19:37:41
    Re: Gallery.AllItems with ForAll / Collect Question

    Nevermind, it was a problem between the chair and the keyboard. I copy/pasted the code from the individual save button and I forgot to remove the .selected reference. The correct code is:

     

    orAll(EquipmentGallery_DetailsScreen.AllItems,
     Collect(ModifiedCollection, 
     {
     RequestID: RequestID,
     ID: ID,
     AssetID: AssetIDTextboxInput_DetailsScreen.Text,
     VIN: VINTextboxInput_DetailsScreen.Text,
     Vendor: VendorTextboxInput_DetailsScreen.Text,
     IsPending: !(IsPendingToggle_DetailsScreen.Value),
     FulfilledBy: If( !(IsPendingToggle_DetailsScreen.Value) = false, varCurrentUser.Email),
     FulfilledDate: If( !(IsPendingToggle_DetailsScreen.Value) = false, conDateTime),
     IsAssetIDAssigned: If(IsBlank(AssetID), false, true)
     }
     )
    );

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,645 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 65,997 Most Valuable Professional

Leaderboard
Loading started