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

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
Level 8

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

Awesome as usual - thanks!

Helpful resources

Announcements
thirdimage

Power Platform 24

Check it out!

thirdimage

New Badges

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

Top Solution Authors
Top Kudoed Authors
Users online (4,588)