Hi, I have used the technique offered in this post to set a Requestor person look-up to the current logged in user and to set a Manager field to this person's manager.
https://powerusers.microsoft.com/t5/General-Discussion/PowerApps-People-picker-Current-User/m-p/154794#M52370
All works until I added a formula on the requestor field onChange. The reason is that we have the scenario where people submit the request on behalf of someone else. Therefore the Requestor field may be changed to someone else. The manager field should update to the new Requestor's manager.
The formula I have used:
OnChange
Set(gvCurrentManager, Office365Users.ManagerV2(DataCardValue35.Selected.Email))
Unfortunately this formula caused and error: Office365Users.ManagerV2 failed: The method 'ManagerV2' has an invalid value for parameter 'id'
It is interesting that when using Chrome the error is not highlighted in edit mode. When using Edge, the error is shown. Also, when I first applied the formula it worked in preview mode... then it didn't. Very strange.
Also, in Chrome I was removing and re-adding connections but they were caching. I wasn't able to get the app functional again until I switched to editing in Edge. Was a little stressful to say the least.
My steps to get the default user and manager are shown below for anyone interested. This works!... just have to figure out the onChange formula now. Thanks, and I hope the below steps based on Jeff Thorpe's post helps someone.
In summary:
Welcome Page
OnStart
Set(gvCurrentUser, Office365Users.MyProfileV2());
Set(gvCurrentManager, Office365Users.ManagerV2(gvCurrentUser.userPrincipalName))
EditScreen
Current user datacard value
DefaultSelectedItems
//Default formula for the data card value
If(EditForm1.Mode = FormMode.New,
{
DisplayName: gvCurrentUser.displayName,
Claims: "i:0#.f|membership|" & gvCurrentUser.userPrincipalName
},
Parent.Default
)
Current user datacard
Update
DataCardValue35.Selected
Manager datacard value
Default SelectedItems
//Default formula for the data card value
If(EditForm1.Mode = FormMode.New && Not( gvCurrentManager.userPrincipalName = ""),
{
DisplayName: gvCurrentManager.displayName,
Claims: "i:0#.f|membership|" & gvCurrentManager.userPrincipalName
},
Parent.Default
)
Manager datacard
Selected
DataCardValue17.Selected