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 / OnChange Formula - Upd...
Power Apps
Answered

OnChange Formula - Update Manager Field Person Lookup

(0) ShareShare
ReportReport
Posted on by 651

 

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

 

 

Categories:
I have the same question (0)
  • v-monli-msft Profile Picture
    Microsoft Employee on at

    Hi @Brice235i,

     

    Thanks for sharing your resolution here!

     

    Regards,

    Mona

  • Brice235i Profile Picture
    651 on at

    No problem, but the main reason for posting was to troubleshoot the onChange error.  At least the app is functioning now, but it isn't perfect.

     

    OnChange
    Set(gvCurrentManager, Office365Users.ManagerV2(DataCardValue35.Selected.Email))

     

    The scenario is that someone submits the form on behalf of someone else.  They can change the Requestor name to this person and the Manager field should auto update based on this new requestor.

     

    Thank you!

  • Brice235i Profile Picture
    651 on at

    Hi @v-monli-msft, this wasn't the resolution and I'm being asked to accept the reply as a solution, so I must have done something incorrectly.

     

    I'm still unable to update the onChange property without getting a connection error.

    I am able to sucessfully retrieve the current user and manager, but I need to enable the current user value to be changed, as quite often someone submits the form on behalf of somebody else.  I need to manager field to update to the new current user's manager.  It only worked in Preview mode in Chrome... In Edge an error is displayed against the field.

     

    Do you know what could be wrong with the formula below?

     

    OnChange
    Set(gvCurrentManager, Office365Users.ManagerV2(DataCardValue35.Selected.Email))

     

     

  • Verified answer
    Brice235i Profile Picture
    651 on at

    Hi, finally got this working.

    Corrected onChange Formula:
    If(Len(DataCardValue5.Selected.Email)>0, Set(gvCurrentManager, Office365Users.ManagerV2(DataCardValue5.Selected.Email));Set(varManager, gvCurrentManager))

     

    @v-monli-msft

     
  • ShaikSayyad Profile Picture
    111 on at

    Thanks for sharing it was working as I expected. Could you please let me know to do it for retrive city of DataCardValue35.Selected.Email ??

  • Brice235i Profile Picture
    651 on at

    Hi there, you can try:

    First(Office365Users.SearchUser({searchTerm:DataCardValue10.SearchText})).Department

     

    There is a smiley face...  it isn't funny and wonder if it is a poor attempt at humour from Microsoft.  Instead of the emoji it is a colon and 'D'...   It is irritating that rich text is used for a forum such as this.

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 April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Vish WR Profile Picture

Vish WR 936

#2
Valantis Profile Picture

Valantis 604

#3
11manish Profile Picture

11manish 518

Last 30 days Overall leaderboard