cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
sperry1625
Helper IV
Helper IV

SharePoint List Form: Multi Select Column Detection

I have a multi-select Person column, but this would likely apply to any multi select column in SharePoint. When retrieving data from a SharePoint list, and a column is multi select, in my case a Person column, what is returned varies based on whether the column has 1 or multiple selections.  If there are multiple selections it returns a table of those entries, if it's a single it returns a record.  When working with that column the functions available will vary.  In my example I want to check if the current user is selected in the column. The test conditions I have are as follows:

 

Set( gblUser = User().Email );
Set( gblApp, LookUp( Applications, 'Name (Title)' = gblAppName ) );

// Test if only a single person is selected in column
Set( gblIsAdmin, If( gblUser in gblApp.Admins.Email, true, false ) );

// Test if multiple users are selected in the column
Set( gblIsAdmin, If( IsBlank( LookUp( gblApp.Admins, Email = gblUser ) ), false, true ) );

 

The problem is how to test when to use one over the other. Currently the value only has a single selection, which flags the second test condition as an error because gblApp.Admins is an incorrect type for a Lookup. The flag goes away if Admins has multiple selections.  The first test only works if there is a single selection otherwise always returns false if multiple selections. 

What can I use to test the condition regardless of whether there is one or more selections in the column?

 

Thanks.

1 ACCEPTED SOLUTION

Accepted Solutions
sperry1625
Helper IV
Helper IV

I solved this issue.  There maybe a better way but the below worked for me.

Set( gblApp, LookUp( Applications, 'Name (Title)' = gblAppName ) );

Set( gblUser, User().Email );

// The values for Admins and Owners is copied into a Collection.
// *****************************************************************************
// This is done because the Type of these columns will be different depending on 
//  whether there is one or multiple Persons selected. If only one the data type
//  is Record, if multiple the data type is Table. Collection Creation will take
//  either as a parameter to create the collection. So in the end you have the
//  same data type regardless of what is in the column.  This allows the tests
//  that follow to be the same.
Collect( gblAdmins, gblApp.Admins );
Collect( gblOwners, gblApp.Owners );

Set( gblMembership,
    {
        IsAdmin: If( IsBlank( LookUp( gblAdmins, gblUser in Email ) ), false, true ),
        IsOwner: If( IsBlank( LookUp( gblOwners, gblUser in Email ) ), false, true ),
        IsSubmitter: false
    }
);

// This is optional, I clear the collections as they are no longer needed.
Clear(gblAdmins);
Clear(gblOwners);

I hope this helps someone else. 

View solution in original post

1 REPLY 1
sperry1625
Helper IV
Helper IV

I solved this issue.  There maybe a better way but the below worked for me.

Set( gblApp, LookUp( Applications, 'Name (Title)' = gblAppName ) );

Set( gblUser, User().Email );

// The values for Admins and Owners is copied into a Collection.
// *****************************************************************************
// This is done because the Type of these columns will be different depending on 
//  whether there is one or multiple Persons selected. If only one the data type
//  is Record, if multiple the data type is Table. Collection Creation will take
//  either as a parameter to create the collection. So in the end you have the
//  same data type regardless of what is in the column.  This allows the tests
//  that follow to be the same.
Collect( gblAdmins, gblApp.Admins );
Collect( gblOwners, gblApp.Owners );

Set( gblMembership,
    {
        IsAdmin: If( IsBlank( LookUp( gblAdmins, gblUser in Email ) ), false, true ),
        IsOwner: If( IsBlank( LookUp( gblOwners, gblUser in Email ) ), false, true ),
        IsSubmitter: false
    }
);

// This is optional, I clear the collections as they are no longer needed.
Clear(gblAdmins);
Clear(gblOwners);

I hope this helps someone else. 

View solution in original post

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Power Apps June 2021

June Power Apps Community Call

Did you miss the call? Check out the recording here!

Top Solution Authors
Top Kudoed Authors
Users online (16,863)