cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Frequent Visitor

How to Save a Collection to a Sharepoint List Column?

I have a Sharepoint List (myList) containing records captured from user input in a PowerApp.

The user inputs data into a PowerApp and that data is saved as a record for that user. I test the User().Email to validate and return that users record for edit/modification. This is not my problem though.

As my App has grown (user suggestions), I now include a method for the user to customize the App. The user selects various customizations and I store those customizations into a Collection within PowerApps (userSelections). This Collection has three Columns (role, val, state).

What I would like to do is save this Collection (userSelections) to a Column (SelectedWorkflow) in the users record in the Sharepoint List (myList). When a user returns, and after retreiving that users record, I would like to pull the userSelections Collection out of the SelectedWorkflow Column of their record, and then use that Collection to configure their Customizations.

 

The problem I am facing is in how to store a Collection directly into a Column in Sharepoint. The People Column type does this with PeoplePicker: saves a table of data to the column. I am missing something in trying to do this with a collection, and I cannot find a column type definition in Sharepoint List that holds table data. I hope I am just missing something simple.

Detail with code examples. Note: some code is redacted for simplicity.

Note: Each record in myList has many columns, including UserEmail, SelectedWorkflow, Modified, Etc., Etc., Etc..

On the App load, I create a master Collection (masterWF) with all of the Configuration options. This is hardcoded and not stored in any datasource. I configure this only if new Configuration options are requested.

ClearCollect(
    masterWF,
        {val: "New Document", role: myRoles0.Role1, stat: 0},
        {val: "Start Workflow", role: myRoles0.Role1, stat: 0},
        {val: "Stop Workflow", role: myRoles0.Role1, stat: 0},
        {val: "Resume Workflow", role: myRoles0.Role1, stat: 0},
        {val: "Restart Workflow", role: myRoles0.Role1, stat: 0},
        etc.,
        etc.,
        etc.
)
/*myRoles0 contains Role1, Role2, Role3, etc., each Role containing Text values,
but this is irrelevant to my question.
myRoles0.Role1 can be replaced with "Whatever".
I cut this masterWF list off after 5 values, but the actual list has 40+ values with
different Roles assigned. */

 

I load the masterWF in a Gallery (Gallery1_1) where the user selects values they want. I Filter the masterWF Collection values based on user selections made in the Gallery to create a new Collection (userSelections). The Gallery has a clickable Rectangle with OnSelect set to the following: 

If(IsEmpty(Filter( userSelections, role=ThisItem.role And val=ThisItem.val )),
	Collect( userSelections, ThisItem ),
	Remove( userSelections, ThisItem )
)

 

This is where my problem is: 

A "Save Configuration" Button saves "should save" the userSelections Collection to the SelectedWorkflow Column in myList.

UpdateContext(
    {
        patchResultsWF:
        Patch(
            myList,
            Gallery1_1.Selected.ID,
            {
                SelectedWorkflow:
                userSelections
            }
        )
    }
)

The Configuration Screen OnVisible has the following:

ClearCollect(userSelections, Filter(myList, User().Email in UserEmail).SelectedWorkflow)
/* Where User().Email is compared to the stored value in the users record in the UserEmail column */

 

This should populate the userSelection Collection so I can apply their Configuration to the App. My problem is with the "Save Configuration" patch and me not knowing how to get the userSelections Collection to save into the SelectedWorkflow Column in myList.

My workaround is to use ForAll and Concat to turn the values in the userSelections Collection into a string. Save the string to the Sharepoint List. Load the string from the Sharepoint list, and then Split the string into a Collection. I want to avoid this headache if possible.

Can anyone tell me how to Save a Collection to a Sharepoint List Column? Or if this is possible?

 

Thank you!

 

1 REPLY 1
Highlighted
Resolver II
Resolver II

Re: How to Save a Collection to a Sharepoint List Column?

I don't have the anwer to your specific question but if I can point out how I deal with user prefrences maybe it will help.

I create a seperate list or table with the all columns of user prefrences for your app as well as user email and on the app's OnStart I load the users prefrences into a collaction and assign them into variables and use them in the app. When the preferences change I write them back to the list or table.

 

This method has worked well for me and it's simple and easy to maintain.

 

------------------------------------------------------------------------------OfficePowerUser.com------------------------------------------------------------------------
If this post helps answer your question, please click on
“Accept as Solution” to help other members. If you thought this post was helpful, please give it a Thumbs Up.

Helpful resources

Announcements
August 2020 Community Challenge: Can You Solve These?

August 2020 Community Challenge: Can You Solve These?

We're excited to announce our first cross-community 'Can You Solve These?' challenge!

secondImage

Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

secondImage

Super Users Coming in August

We are excited for the next Super User season.

secondImage

Community User Group Member Badges

FIll out a quick form to claim your community user group member badge today!

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (5,718)