cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
blanghorst Helper III
Helper III

Reading a multi-person SharePoint column into a collection - syntax?

I have a SharePoint column called "Reviewers" which is a multi-person field.  I want to read those users into a collection so that I can add/remove users with buttons and then Patch the resulting collection back to the Reviewers column.    I'm stuck on one small point and need some help with syntax.

 

This is the code I'm using currently:

 

Collect(
InternalReviewers,
{
Claims: DataCardValue2.SelectedItems.Claims, Department:"",
DisplayName: DataCardValue2.SelectedItems.DisplayName,
Email: DataCardValue2.SelectedItems.Email, JobTitle:"", Picture: ""
}
)

 

If I use the code above (DataCardValue2 is the Reviewers column in my form), the collection populates but each column contains a table - for example, the DisplayName column contains a single table with Bob, Jim, Sue, and Sally.  The Claims column has a single table with their corresponding Claims, etc.  My questions:

 

1. I'd like for each person to have a single row.  So in this example, I'd want Bob to have a single row in the Collection with his DisplayName, Claims, Email, etc.  The next row would be Jim and his attributes, then Sue, and then Sally.   Ideally, the logic would be something like the following: (I know the For syntax is wrong, but I'm trying to illustrate what I want to do):

 

Set(PersonCount, CountRows(DataCardValue2.SelectedItems);

 

For i = 1 to PersonCount{

Collect(
InternalReviewers,
{
Claims: DataCardValue50_1.Selected(i).Claims, Department:"",
DisplayName: DataCardValue50_1.Selected(i).DisplayName,
Email: DataCardValue50_1.Selected(i).Email, JobTitle:"", Picture: ""
}
)

}

 

Is something like this possible?  I want to loop through the multi-person field and add each user to his/her own row in the collection.  It would also make removing users from the collection pretty easy.

 

2.  If this isn't possible, what's another approach I could consider?

 

I'm pretty close to having this all working, I just need some advice.

1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

Re: Reading a multi-person SharePoint column into a collection - syntax?

@blanghorst
The simplest way to Collect all of the people selected would be

 

Collect(InternalReviewers, DataCardValue2.SelectedItems)

 

But if you want the department, jobtitle and picture to be blank then do this instead.

 

Collect(
    InternalReviwers,
    AddColumns(
        ShowColumns(DataCardValue4.SelectedItems,"Claims","DisplayName","Email"),
        "Department", "",
        "JobTitle", "",
        "Picture", ""
    )
)

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

View solution in original post

2 REPLIES 2
Super User
Super User

Re: Reading a multi-person SharePoint column into a collection - syntax?

@blanghorst
The simplest way to Collect all of the people selected would be

 

Collect(InternalReviewers, DataCardValue2.SelectedItems)

 

But if you want the department, jobtitle and picture to be blank then do this instead.

 

Collect(
    InternalReviwers,
    AddColumns(
        ShowColumns(DataCardValue4.SelectedItems,"Claims","DisplayName","Email"),
        "Department", "",
        "JobTitle", "",
        "Picture", ""
    )
)

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

View solution in original post

blanghorst Helper III
Helper III

Re: Reading a multi-person SharePoint column into a collection - syntax?

Awesome as usual - thanks!

Helpful resources

Announcements
MBAS Gallery 2020

MBAS Gallery 2020

Watch Microsoft Business Applications Summit sessions on-demand.

‘Better Together’ T-Shirt Contest – Winner Announced!

‘Better Together’ T-Shirt Contest – Winner Announced!

And the winner is...

firstImage

New Ranks and Rank Icons released on April 21!

The time has come: We are finally able to share more details on the brand-new ranks coming to the Power Apps Community!

Power Platform 2020 release wave 1 plan

Power Platform 2020 release wave 1 plan

Features releasing from April 2020 through September 2020

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