cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Skilled Sharer
Skilled Sharer

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
Skilled Sharer
Skilled Sharer

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
Skilled Sharer
Skilled Sharer

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
New Badges

New Solution Badges!

Check out our new profile badges recognizing authored solutions!

New Power Super Users

Congratulations!

We are excited to announce the Power Apps Super Users!

Power Apps Community Call

Power Apps Community Call: February

Did you miss the call? Check out the Power Apps Community Call here.

Microsoft Ignite

Microsoft Ignite

Join digitally, March 2–4, 2021 to explore new tech that's ready to implement. Experience the keynote in mixed reality through AltspaceVR!

Top Solution Authors
Top Kudoed Authors
Users online (13,146)