cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
dmorland
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
mdevaney
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
mdevaney
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
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

PA Community Call

Power Apps Community Call

Next call is happening on April 21st at 8a PST.

MBAS Carousel

Sign up for our May 4th event!

May the fourth be with you, join us online!

secondImage

Experience what’s next for Power Apps

See the latest Power Apps innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Top Solution Authors
Top Kudoed Authors
Users online (41,692)