web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Office365Users objects...
Power Apps
Answered

Office365Users objects and questions

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

I am building an object to use in my training exercise. I have the following. 

Set(
 userObj,
 {
 Profile: Office365Users.MyProfile(),
 Picture: Office365Users.UserPhoto(User().Email),
 Manager: Office365Users.Manager(User().Email),
 isManager: Office365Users.SearchUser({searchTerm: 
 Office365Users.Manager(User().Email).DisplayName})
 }
);

 

When I insert a label and try to reference isManager(ie.. userObj.isManager) it says "Expected Text Value". So I'm trying to figure out how to convert that here for one. 

Second, if I run this command in my label. 
First(Office365Users.SearchUser({searchTerm: Office365Users.Manager(User().Email).DisplayName})).DisplayName

I get a value, however if I add the First() in my userObj it does not work. Can someone help understand what I'm doing wrong?

 

 

Categories:
I have the same question (0)
  • Al_10 Profile Picture
    1,691 Super User 2024 Season 1 on at

    What if you try:


    Set(
    userObj,
    {
    Profile: Office365Users.MyProfile(),
    Picture: Office365Users.UserPhoto(User().Email),
    Manager: Office365Users.Manager(User().Email),
    isManager:
    First(Office365Users.SearchUser({searchTerm: Office365Users.Manager(User().Email)})).DisplayName
    }
    );

     

    label = userObj.isManager

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    the Set doesn't like it, it says "The function SearchUser has some invalid arguments.

  • Al_10 Profile Picture
    1,691 Super User 2024 Season 1 on at

    Set(varCurrentUserEmail, User().Email);
    Set(
    userObj,
    {
    Profile: Office365Users.MyProfile(),
    Picture: Office365Users.UserPhoto(varCurrentUserEmail),
    Manager: Office365Users.Manager(varCurrentUserEmail),
    isManager:
    First(Office365Users.SearchUser({searchTerm: Office365Users.Manager(varCurrentUserEmail).Mail})).DisplayName
    }
    );

     

    label = userObj.isManager

    edited

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    @Anonymous Try this..

     

    Set(
     userObj,
     {
     Profile: Office365Users.MyProfile(),
     Picture: Office365Users.UserPhoto(User().Email),
     Manager: IfError(Office365Users.Manager(User().Email),Blank()),
     isManager: CountRows(Office365Users.DirectReports(Office365Users.MyProfileV2().id)) > 0
     }
    );

     

    To reference the use's manager, use this (since you're setting Manager to the Manager object.

     

    userObj.Manager.DisplayName

    ---
    If this answered your question, please click "Accept Solution". If this helped, please Thumbs Up.

     

  • Verified answer
    v-xida-msft Profile Picture
    Microsoft Employee on at

    Hi @Anonymous ,

    What value do you want to store within the isManager column? Text value or Boolean value?

    Do you detect if current user is also a Manager?

     

    If you just want to store the retrieved "DisplayName" value into the isManager column, please modify your formula as below:

    Set(
     userObj,
     {
     Profile: Office365Users.MyProfile(),
     Picture: Office365Users.UserPhoto(User().Email),
     Manager: Office365Users.Manager(User().Email),
     isManager: First(Office365Users.SearchUser({searchTerm: Office365Users.Manager(User().Email).DisplayName})).DisplayName 
     }
    );

     

    If you want to detect if current user is also an Manager, you need to store a Boolean value in the 'isManager' field. You need to modify your formula as below:

    Set(
     userObj,
     {
     Profile: Office365Users.MyProfile(),
     Picture: Office365Users.UserPhoto(User().Email),
     Manager: Office365Users.Manager(User().Email),
     isManager: If(
     !IsEmpty(Office365Users.DirectReportsV2(User().Email).value),
     true,
     false
     ) 
     }
    );

     

    Then within your canvas app, you could reference the isManager column value through the following formula:

    userObj.isManager

     

    Please try above solution, then check if the issue is solved.

     

    Regards,

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 324 Most Valuable Professional

#2
11manish Profile Picture

11manish 193

#3
Valantis Profile Picture

Valantis 138

Last 30 days Overall leaderboard