Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Building 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: ""
}
                }
            )
        )
    )
)
  • MarwaAlhajri Profile Picture
    on at
    Re: patch users manager name

    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

     

  • Michael E. Gernaey Profile Picture
    41,027 Super User 2025 Season 1 on at
    Re: patch users manager name

    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

     

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,658 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 65,999 Most Valuable Professional

Leaderboard