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 / Auto Populate ancillia...
Power Apps
Unanswered

Auto Populate ancilliary User profile fields based on person look-up field that is auto-populated as CurrentUser

(0) ShareShare
ReportReport
Posted on by 651

Hi, I have managed to get the Current user to auto-populate in a SharePoint person lookup datacard.  However the anciliary fields - department, Jobtitle, phone etc do not auto-populate onload.

 

App OnStart - Set(gvCurrentUser, Office365Users.MyProfileV2());

 

Name  - DefaultSelectedItems (SharePoint Person Look-up)

If(EditForm1.Mode = FormMode.New,

{DisplayName: gvCurrentUser.displayName,Claims: "i:0#.f|membership|" & gvCurrentUser.userPrincipalName},

Parent.Default)

Anciliary Field e.g. Department - Default

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

 

In the example above the Department field is blank when the form is opened.  When I delete the name in the Name person look-up field and re-enter, the Department field populates as expected...  it just isn't automatically appearing on load.

 

You might ask, why I wouldn't just enter as the default value for the Department field -

Office365Users.MyProfile().JobTitle 

The trouble is, often an administrator enters the form on behalf of somebody, so they need to overwrite the currentUser value.  When this occurs, the anciliary fields should update to reflect this change.  Therefore the MyProfile() option is not suitable.

 

Would anyone know how I get these anciliary fields populating based on the value in the Person lookup onload?  All of these listed below:

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

First Name: First(Office365Users.SearchUser({searchTerm:DataCardValueofName.SearchText})).GivenName

Job Title: Office365Users.UserProfile(DataCardValueofName.Selected.Email).jobTitle

Email: Office365Users.UserProfile(DataCardValueofName.Selected.Email).Mail

Mobile Phone: Office365Users.UserProfile(DataCardValueofName.Selected.Email).mobilePhone

Last Name: First(Office365Users.SearchUser({searchTerm:DataCardValueofName.SearchText})).Surname

 

 

Categories:
I have the same question (0)
  • Verified answer
    Brice235i Profile Picture
    651 on at

    Worked this out

    Hi, I have managed to get the Current user to auto-populate in a SharePoint person lookup datacard.  However the anciliary fields - department, Jobtitle, phone etc do not auto-populate onload.

     

    App OnStart - Set(gvCurrentUser, Office365Users.MyProfileV2());

     

    Name  - DefaultSelectedItems (SharePoint Person Look-up)

    If(EditForm1.Mode = FormMode.New,

    {

    DisplayName: gvCurrentUser.displayName,

    Claims: "i:0#.f|membership|" & gvCurrentUser.userPrincipalName,
    Department:"",

    Email:User().Email,

    JobTitle:"",

    Picture:""

    },

    Parent.Default

    )

    Anciliary Field Default Value

    Department 

    If(Len(EmployeeDataCardValue.Selected.Email)>0,Office365Users.UserProfile(EmployeeDataCardValue.Selected.Email).Department)

    First Name:

    If(Len(DataCardValueNAME.Selected.Email)>0,Office365Users.UserProfile(DataCardValueNAME.Selected.Email).GivenName)

    Job Title: If(Len(DataCardValueNAME.Selected.Email)>0,Office365Users.UserProfile(DataCardValueNAME.Selected.Email).JobTitle)

    Email: If(Len(DataCardValueNAME.Selected.Email)>0,Office365Users.UserProfile(DataCardValueNAME.Selected.Email).Mail)

    Mobile Phone: If(Len(DataCardValue6.Selected.Email)>0,Office365Users.UserProfile(DataCardValue6.Selected.Email).mobilePhone)

    Last Name:

    If(Len(DataCardValueNAME.Selected.Email)>0,Office365Users.UserProfile(DataCardValueNAME.Selected.Email).Surname)

    Business Phone:

    If(Len(DataCardValueNAME.Selected.Email)>0,First(Office365Users.UserProfile(DataCardValueNAME.Selected.Email).BusinessPhones).Value)

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