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
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: ""
}
}
)
)
)
)