cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
KarlNixon
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

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 III
Super User III

@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
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Power Apps June 2021

June Power Apps Community Call

Did you miss the call? Check out the recording here!

Top Solution Authors
Top Kudoed Authors
Users online (35,118)