cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
MikeAnderson
Level 8

Gallery.AllItems with ForAll / Collect Question

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!

1 ACCEPTED SOLUTION

Accepted Solutions
MikeAnderson
Level 8

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)
        }
    )
);

View solution in original post

1 REPLY 1
MikeAnderson
Level 8

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)
        }
    )
);

View solution in original post

Helpful resources

Announcements
thirdimage

Power Apps Super User Class of 2020

Check it out!

thirdimage

Power Apps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

SecondImage

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Top Solution Authors
Top Kudoed Authors (Last 30 Days)
Users online (3,048)