cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper I
Helper I

Creating a collection based on merged variables

Calling out to the brainstrust.

 

I'm trying to create a collection of employees by role based on the following variable:

 

Set(VarUser,
{
MyProfile: Office365Users.MyProfileV2(),
DirectReports: Office365Users.DirectReportsV2(User().Email),
MyManager: Office365Users.ManagerV2(User().Email)
}
);

 

All I want is employee email and role (Me, Manager or Direct report)

 

Any ideas on how to create a collection with these attributes?

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Microsoft
Microsoft

Re: Creating a collection based on merged variables

Hi @KarlNixon:

Because the data format and type of the return values of these three functions(Office365Users.DirectReportsV2(User().Email), Office365Users.ManagerV2(User().Email) and Office365Users.MyProfileV2()) are different, the key is to reshape the table by adding, deleting, renaming, and selecting its columns.

I sugget you try this code:

 

ClearCollect(
    colRoles1,
    {
        Email: User().Email,
        Role: "Me"
    },
    ShowColumns(RenameColumns(
        AddColumns(
            Office365Users.DirectReportsV2(User().Email).value.mail,
            "Role",
            "Direct Report"
        ),
        "mail",
        "Email"
    ),"Email","Role"),
    {
        Email: Office365Users.ManagerV2(User().Email).mail,
        Role: "Manager"
    }
)

 

 Best Regards,

Bof

View solution in original post

5 REPLIES 5
Highlighted
Helper V
Helper V

Re: Creating a collection based on merged variables

Office365Users.MyProfileV2() Gives you an object. 
so you are creating a variable with several objects inside. 

Use only the Things you need:

for example: Office365Users.MyProfileV2().email

Highlighted
Super User
Super User

Re: Creating a collection based on merged variables

@KarlNixon 
Can you please give an example of what the output collection should look like?  I'm trying to understand what the structure of your collection should look like.

 

Here's the first idea I had to get you started...

 

ClearCollect(
    colRoles,
    AddColumns(Office365Users.MyProfileV2(),"Role", "Me"),
    AddColumns(Office365Users.DirectReportsV2(User().Email),"Role","Direct Report"),
    AddColumns(Office365Users.ManagerV2(User().Email),"Role", "Manager")
)

 

---
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."

Highlighted
Helper I
Helper I

Re: Creating a collection based on merged variables

@mdevaney 

 

The collection would look like this

 

EmailRole
karl.nixon@fakemail.comMe
david.bowie@fakemail.comDirect Report
elton.john@fakemail.comDirect Report
joe.strummer@fakemail.comDirect Report
paul.kelly@fakemail.comDirect Report
elvis.costello@fakemail.comManager

 

 

 

Highlighted
Microsoft
Microsoft

Re: Creating a collection based on merged variables

Hi @KarlNixon:

Because the data format and type of the return values of these three functions(Office365Users.DirectReportsV2(User().Email), Office365Users.ManagerV2(User().Email) and Office365Users.MyProfileV2()) are different, the key is to reshape the table by adding, deleting, renaming, and selecting its columns.

I sugget you try this code:

 

ClearCollect(
    colRoles1,
    {
        Email: User().Email,
        Role: "Me"
    },
    ShowColumns(RenameColumns(
        AddColumns(
            Office365Users.DirectReportsV2(User().Email).value.mail,
            "Role",
            "Direct Report"
        ),
        "mail",
        "Email"
    ),"Email","Role"),
    {
        Email: Office365Users.ManagerV2(User().Email).mail,
        Role: "Manager"
    }
)

 

 Best Regards,

Bof

View solution in original post

Highlighted
Helper I
Helper I

Re: Creating a collection based on merged variables

@v-bofeng-msft 

 

Fantastic - thanks so much for your guidance!

 

Accepted as solution

 

 

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 (6,770)