cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
KarlNixon
Helper II
Helper II

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

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
max81
Kudo Kingpin
Kudo Kingpin

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

mdevaney
Super User
Super User

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

@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

 

 

 

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

@v-bofeng-msft 

 

Fantastic - thanks so much for your guidance!

 

Accepted as solution

 

 

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (1,764)