cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Brice235i
Level 8

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

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

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Brice235i
Level 8

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

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)

View solution in original post

1 REPLY 1
Brice235i
Level 8

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

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)

View solution in original post

Helpful resources

Announcements
thirdimage

Power Apps Super User Class of 2020

Check it out!

thirdimage

Power Apps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

SecondImage

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Top Solution Authors
Top Kudoed Authors (Last 30 Days)
Users online (5,749)