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

Merging collections using ForAll and Patch

I created a gallery with checkboxes for users to select their favourite apps. User's choices get stored in a SharePoint list called MyApps.

 

On app start a collection is created that fetches the current user's app choices. This is displayed in the following nested gallery.

 

Screen Shot 2019-11-19 at 17.47.24.png

When the user clicks an edit button, I want to show all the available apps that can be selected with the checkboxes ticked to indicate selected apps. 

 

Screen Shot 2019-11-19 at 17.51.36.png

Checkbox OnCheck code 

UpdateContext({varListEdited:true});
Patch(
    colSavedApps,
    ThisItem,
    {
        AppSelected:true
    }
);

 

I'm struggling how to get all apps to display in Edit Mode. Only the apps user has selected get saved to SharePoint so the unselected ones aren't displayed in the gallery. Originally I patched all selections whether yes or no to the list in a column called AppSelected, but this method stored lots of unnecessary rows, so I opted to store only 'Yes' selections in SharePoint.

 

I have another SharePoint list with just the app names. I was wondering if it's possible to merge two collections to add the unselected apps to the collection with an AppSelected status of false? This way I could filter on AppSelected to show/hide when the edit button is pressed.

 

I want to compare two collections and add missing items to collection1 from collection2. I've been trying to use ForAll and patch but not had success. The apps in SharePoint list 1 and SharePoint list 2 that would populate the collections share most of the same columns with Title being the best candidate for cross referencing.

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Digital
Level 8

Re: Merging collections using ForAll and Patch

To solve this I created two galleries - one with saved user selected apps from SharePoint, and another containing all app options. When the user hits edit the app selections from the first gallery are patched to the second gallery.

 

Here is how achieved this. Formulae is triggered by OnSelect of edit button. When user hits save the 2nd gallery choices are patched to SharePoint and the first gallery is updated to show the new selections.

 

Apologies for the not very good description of the problem in the first post, but hopefully someone experiencing a similar issue could  follow.

 

ForAll(
    RenameColumns(colSavedApps,"Title","ThisTitle"),
    Patch(
        colAppList,
        LookUp(
            colAppList,
            Title = ThisTitle
        ),
        {rnzAppSelected: rnzAppSelected}
    )
);
UpdateContext({varReset:true});
UpdateContext({varReset:false});

 

View solution in original post

2 REPLIES 2
Digital
Level 8

Re: Merging collections using ForAll and Patch

I made a second gallery with a collection containing all the app options, but they can only be all checked or all unchecked.

 

If I could set all the checked items in the first gallery/collection to be checked in the second that may solve my problem as I could just show/hide the galleries when user presses edit. When user presses save, the 2nd gallery choices could be patched to SharePoint list and refresh collection in gallery 1. 

Digital
Level 8

Re: Merging collections using ForAll and Patch

To solve this I created two galleries - one with saved user selected apps from SharePoint, and another containing all app options. When the user hits edit the app selections from the first gallery are patched to the second gallery.

 

Here is how achieved this. Formulae is triggered by OnSelect of edit button. When user hits save the 2nd gallery choices are patched to SharePoint and the first gallery is updated to show the new selections.

 

Apologies for the not very good description of the problem in the first post, but hopefully someone experiencing a similar issue could  follow.

 

ForAll(
    RenameColumns(colSavedApps,"Title","ThisTitle"),
    Patch(
        colAppList,
        LookUp(
            colAppList,
            Title = ThisTitle
        ),
        {rnzAppSelected: rnzAppSelected}
    )
);
UpdateContext({varReset:true});
UpdateContext({varReset:false});

 

View solution in original post

Helpful resources

Announcements
thirdimage

Power Automate 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

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors (Last 30 Days)
Users online (5,597)