cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Brice235i
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
Brice235i
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
Brice235i
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
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Power Apps June 2021

June Power Apps Community Call

Don't miss the call this month on June 16th - 8a PDT

Top Solution Authors
Top Kudoed Authors
Users online (83,490)