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

CDS: Updating a lookup field (User) with data from Office365Users

All,

 

I have a custom entity in CDS named CheckListItem with a field named AssignedTo. This is a lookup field to User entity, also in CDS.

 

I my app, I have a gallery named galCheckListItems. The data source for this gallery is a collection based on the CheckListItem entity named colCheckListItems, created as below:

 

Items:

ClearCollect(colCheckListItems, Filter(<my filter criteria>))

 

Within this gallery, I created a People Picker control named cmbAssignTo connected to Office365Users data source. This is how I have set it up:

Items: Office365Users.SearchUser({searchTerm: cmbAssignTo.SearchText})

DisplayFields: ["DisplayName","JobTitle"]

SearchFields: ["DisplayName","JobTitle"]

SelectMultiple: False

Default:

 

I also have a button outside the gallery named btnSave.

 

Here are my requirements:

  1. The user will search for and select a user through the cmbAssignTo People Picker. This is working;
  2. The app should update the AssignedTo field in the collection with the user selected in previous step. I’m using OnChange action for that, but I could not make it work. I’m having all kinds of errors (different schema, data type compatibility issues, etc.);
  3. I want the People Picker (cmbAssignTo) to display the user (if any) stored on the colCheckListItems I tried setting its Default property to ThisItem.AssignedTo but it did not work;
  4. When user clicks the btnSave button, I want the app to save the data on the colCheckListItems collection back to CheckListItem

Any help is highly appreciated. Thank you.

1 ACCEPTED SOLUTION

Accepted Solutions
v-monli-msft
Community Support
Community Support

Hi @ArleiSilva ,

 

What is the property type of the field AssignedTo shows? DisplayName, JobTitle, Department or what? 

 

For example, its a name list and you include all the names of AssignedTo contained in a dropdown control called Names, do this by setting the Items property of this dropdown control to:

Distinct(CheckListItem,AssignedTo)

Then you can use this expression to only show results with that displayname  :

Filter(
    Office365Users.SearchUser({ searchTerm: SearchTerm.Text }),
    DisplayName = Names.Selected.Value)

 

Regards,

Mona

Community Support Team _ Mona Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

1 REPLY 1
v-monli-msft
Community Support
Community Support

Hi @ArleiSilva ,

 

What is the property type of the field AssignedTo shows? DisplayName, JobTitle, Department or what? 

 

For example, its a name list and you include all the names of AssignedTo contained in a dropdown control called Names, do this by setting the Items property of this dropdown control to:

Distinct(CheckListItem,AssignedTo)

Then you can use this expression to only show results with that displayname  :

Filter(
    Office365Users.SearchUser({ searchTerm: SearchTerm.Text }),
    DisplayName = Names.Selected.Value)

 

Regards,

Mona

Community Support Team _ Mona Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Users online (2,996)