cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Frequent Visitor

Retrieve person attributes from Sharepoint list field

I have a form that is linked to a Sharepoint list. One of the columns in the Sharepoint list is called Requestor and it used to store a person from the directory.


The form has a combobox linked to the Requestor field in the Sharepoint list. The combobox has DisplayFields ["DisplayName","Email","Picture"] and SearchFields ["DisplayName"]

 

I am able to use the combobox to select a person.

 

I want a button to add information about the Requestor to a collection. I want the DisplayName, Email and the ID of the person as separate fields in the collection. I am having difficulty working out how to access these attributes from the the person selected in the combobox. I think I have to use Office365Users to access these attributes but all my attempts to retrieve the person based on what is in the combobox have failed.

 

I think I just need an example of how to retrieve the displayname and email address for the user John Brown assuming this person is selected as the Requestor on  my form and to have one label set to the displayname and a second label set to the email address.

1 ACCEPTED SOLUTION

Accepted Solutions
Super User III
Super User III

@dmorland 

Assuming your ComboBox is populated with Person objects you should be able to access their details.  To test try putting each of these code lines in a separate label within the Text property.

 

ComboBox.Selected.ID
ComboBox.Selected.DisplayName ComboBox.Selected.Email

 

You can PATCH the information into your datasource using the code below.  Please note, DataCardValue_ID.Text refers to a datacard for the record ID.  You must add it to your form but it can be invisible.

 

Patch(
    your_datasource_name,
    LookUp(your_datasource_name, ID=DataCardValue_ID.Text
    {
        EmployeeID: ComboBox.Selected.ID,
        DisplayName: ComboBox.Selected.DisplayName,
        Email: ComboBox.Selected.Email
    }
)

 

Let me know if this helps!

 

---
Please click "Accept as Solution" if my response helped to solve your issue so that others may find it more quickly. If your thought the post was helpful please give it a "Thumbs Up."

View solution in original post

3 REPLIES 3
Super User III
Super User III

@dmorland 

Assuming your ComboBox is populated with Person objects you should be able to access their details.  To test try putting each of these code lines in a separate label within the Text property.

 

ComboBox.Selected.ID
ComboBox.Selected.DisplayName ComboBox.Selected.Email

 

You can PATCH the information into your datasource using the code below.  Please note, DataCardValue_ID.Text refers to a datacard for the record ID.  You must add it to your form but it can be invisible.

 

Patch(
    your_datasource_name,
    LookUp(your_datasource_name, ID=DataCardValue_ID.Text
    {
        EmployeeID: ComboBox.Selected.ID,
        DisplayName: ComboBox.Selected.DisplayName,
        Email: ComboBox.Selected.Email
    }
)

 

Let me know if this helps!

 

---
Please click "Accept as Solution" if my response helped to solve your issue so that others may find it more quickly. If your thought the post was helpful please give it a "Thumbs Up."

View solution in original post

Hi, thx for your help.  This worked ok for retrieving the DisplayName and Email but not the ID.  I was able to get the ID using:

 

First(Office365Users.SearchUser({searchTerm: DataCardValue2.Selected.DisplayName, top:1})).Id

@dmorland 

Excellent.  I am glad you were able to find the solution.  Please close this thread so others know the problem was solved. Cat Happy

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 (38,315)