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

Notifications

Announcements

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,323 Super User 2025 Season 2 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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 796 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 327 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard