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 / patch users manager name
Power Apps
Unanswered

patch users manager name

(1) ShareShare
ReportReport
Posted on by

Hi guys 

 

I have created an app to collect Office 365 user info and patch them in the SharePoint list 

the thing is it only patches the current user line manager, I want to patch each employee line manager 

I have used below code 

ForAll(
    Filter(
        Office365Users.SearchUser(),
        AccountEnabled = true
    ),
    With(
        {
            ExistingItem: LookUp(
                'Employee information list',
                Email = Mail
            )
        },
        If(
            IsBlank(ExistingItem),
            // If the user does not exist, create a new item
            Patch(
                'Employee information list',
                Defaults('Employee information list'),
                {
                   
                    Display_name: DisplayName,
                    Phone_number: mobilePhone,
                    First_name: GivenName,
                    Department_Name: Department,
                    'designation ':JobTitle,
                    Email: Mail,
                    'Line Manager1':{
    '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
    Claims: "i:0#.f|membership|" & Office365Users.ManagerV2(User().Email).displayName,
    Department: "",
    DisplayName: Office365Users.ManagerV2(User().Email).displayName,
    Email: Office365Users.ManagerV2(User().Email).mail,
    JobTitle: "",
    Picture: ""
}
                   
                }
            ),
            // If the user exists, update the existing item
            Patch(
                'Employee information list',
                ExistingItem,
                {
                    Display_name: DisplayName,
                    Phone_number: mobilePhone,
                    First_name: GivenName,
                    Department_Name: Department,
                    Email:Mail,
                    'designation ':JobTitle,
                                   'Line Manager1':{
    '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
    Claims: "i:0#.f|membership|" & Office365Users.ManagerV2(User().Email).displayName,
    Department: "",
    DisplayName: Office365Users.ManagerV2(User().Email).displayName,
    Email: Office365Users.ManagerV2(User().Email).mail,
    JobTitle: "",
    Picture: ""
}
                }
            )
        )
    )
)
Categories:
I have the same question (0)
  • Michael E. Gernaey Profile Picture
    53,976 Moderator on at

    Hi @MarwaAlhajri 

     

    At a first glance your code seems fine. And based on what you have the only way it was act how you describe is if, the user only has permissions to retrieve their own record (which could be the case).

     

    When you are coding and running it in the Studio do you only get 1 record?

     

    Also to verify, if you do a CountRows(Office365Users.SearchUsers()) etc does it only give you 1? because saying it only updates the logged in person, if true, makes it sound as if its a permission problem and the person cannot retrieve any other records.

     

    Can you put a Label on the screen and set the Text to the CountRows of the Search so that you can tell for sure how many rows it should be processing.


    If I have helped you, I would really appreciate if you please Mark my answer as Resolved/Answered, and give it a thumbs up, so it can help others

    Cheers

    Thank You
    Michael Gernaey MCT | MCSE | MCP | Self-Contractor| Ex-Microsoft
    https://gernaeysoftware.com
    LinkedIn: https://www.linkedin.com/in/michaelgernaey

     

  • MarwaAlhajri Profile Picture
    on at

    Hi thanks for your reply count rows show me 66 records which all the employees 

    MarwaAlhajri_0-1719898358588.png

    originally I used 

    'Line Manager1':{
    '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
    Claims: "i:0#.f|membership|" & Office365Users.ManagerV2(User().Email).displayName,
    Department: "",
    DisplayName: Office365Users.ManagerV2(User().Email).displayName,
    Email: Office365Users.ManagerV2(User().Email).mail,
    JobTitle: "",
    Picture: ""

    then change it to (User().Email)

    but still the same issue please see my list 

    MarwaAlhajri_1-1719898508207.png

     

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Vish WR Profile Picture

Vish WR 633

#2
11manish Profile Picture

11manish 588

#3
Valantis Profile Picture

Valantis 457

Last 30 days Overall leaderboard