cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Kudo Kingpin
Kudo Kingpin

Re: Collecting multiple SharePoint people with IDs from main row

Thanks so much for your work on this!! I think this is so very close, I hope I can get the final piece to work...

 

As written, the collection colLeaders looks like this as each organization can have more than one leader...

 

 

LeadersDisplayName.png

LeadersDisplayNameCode.png

Highlighted
Resident Rockstar
Resident Rockstar

Re: Collecting multiple SharePoint people with IDs from main row

@PhilD 

I assumed that your Person column was a single select only, but I see it must be set as 'Allow multiple selections: Yes'. Is this correct?

 

So, solving this officially broken my brain, haha - a table inside a table gets messy! All you need to do is adjust your ForAll() to the below:

 

ForAll(ShowColumns(
    Organizations,"Leaders","ID"),
    ForAll(Leaders,
    Collect(colLeaders, {LeaderDisplayName: DisplayName, OrgID: ID}));

 

All the rest of the code can stay the same.

 

Nice challenge, I think it's solved now but let me know if you still get stuck!

 

Edit: I should've added my output to demo this codes' result, here it is (Note: Leaders can have the same OrgID in their list):

Leaders by OrgID - ForAll x 2.jpg

 

 

View solution in original post

Highlighted
Kudo Kingpin
Kudo Kingpin

Re: Collecting multiple SharePoint people with IDs from main row

That's it! This works great now!

 

Thanks so much @Eelman and @WarrenBelz for solving this for me. You guys are awesome! This will help me in other apps as well.

 

Final code

// clear colLeaders first, for obvious reasons
Clear(colLeaders);
// collect into colLeaders a table of names and IDs
// here, I've used my SP ID column but you use your relevant OrgID column name
ForAll(
    ShowColumns(
        Organizations,
        "Leaders",
        "ID"
    ),
    ForAll(
        Leaders,
        Collect(
            colLeaders,
            {
                LeaderDisplayName: DisplayName,
                OrgID: ID
            }
        )
    )
);
// Use GroupBy to build the Leaders collection with their assigned OrgIDs
// Unfortunately you can't use GroupBy directly on your SP list due to delegation issues, however,
ClearCollect(
    colLeaderGrouped,
    DropColumns(
        AddColumns(
            GroupBy(
                colLeaders,
                "LeaderDisplayName",
                "ListOfIDs"
            ),
            "OrganizationIDs",
            Concat(
                ListOfIDs,
                Text(OrgID),
                ", "
            )
        ),
        "ListOfIDs"
    )
)

 

Helpful resources

Announcements
secondImage

Demo-Extravaganza 2020

Check out these cool Power Apps & vote on your favorite!

secondImage

Community Highlights

Check out whats happening in Power Apps

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 (10,220)