cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper II
Helper II

I am confused as to how to set the DefaultItems in a ComboBox to a saved user ID

I am confused as to how to set the DefaultItems in a ComboBox to a saved user ID.

My ComboBox is set to only allow one selection. 

The Items property is set to: Office365Users.SearchUser({top:999})

I save the ID from that selected record when the user saves the form, to a SQL table.

But when the user comes back to edit the form, I'd like to have the4 ComboBox default to their saved value from the Table. But I am confused at how to set the Selected (or SelectedItems) Property. Nothing I do seems to be valid. 

Any help would be terrific. Thanks!

7 REPLIES 7
Highlighted
Super User III
Super User III

Hi @dBrand ,

You have not provided the field name you are storing it in - I will use YourUserField below and assume you are using the DisplayName in the selection, so the DefaultSelectedItems would be

{DisplayName:ThisItem.YourUserField}

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Highlighted

I am storing it in field ID, but I get it. However, It doesn't appear to actually set the Combo box to that record, as I am unable to user the ComboBox.Selected to populate other fields with values from that User (such as email). Not sure if that means I'm missing something or need to do a lookup?

Highlighted

@dBrand ,

I did a test here and using the Items

Office365Users.SearchUser({top:999}).DisplayName

in a ComboBox, then populating a Text field (I am not sure how you are using ID as it is Numeric) with the Update of the card

ComboBoxName.Selected.DisplayName

 was able to get it to display back using what I posted.

What are you doing different?

Highlighted

In the ComboBox DefaultSelectedItems I have:  {DisplayName:ThisItem.ManagerFName&" "& ThisItem.ManagerLName}  (I wanted to use DisplayName, but that's not a choice).

 

If I select a name from the ComboBox dropdown, it properly shows me the other fields in other text boxes. But I only save the ID of that user in my database. When I call up a saved record, it shows me the first and last name in the ComboBox, but the other boxes/fields that show the other fields for that selected item (such as ComboBoxSelected.Mail) do not show anything. This leads me to believe that the record is not really selected in the ComboBox. If I reselect a name in the ComboBox, it then shows me that records details in those other fields/boxes.

 

I hope that makes sense.

Highlighted

HI @dBrand ,

This is a bit of an expansion on the issue and I would suspect your other fields have some sort of relationship with this combo box?

I assume you are writing back the concatenated result somewhere (what is the combo box updating and with what data)?

Highlighted

Let me try explaining my screen a bit more.

I have a form that the user uses to add users to a database. The same form is used to create the user and to edit the user.

 

The fields are: A ComboBox that is connected to Office365Users. When the user selects someone from the ComboBox, I have it saving the User365.User.Id (as I assume the ID field is unique), but I have the ComboBox showing the User Name (which is what I want. I don't need the user to see the ID and use it behind the scenes).

 

Other fields will then populate based on the selection in the ComboBox, such as first name, last name, email address. But, I only write back the Office365.User.id value to the database, as I can use that to find the rest of the info when needed. Saving the record works fine. It's when I go to EDIT the records (FormEdit) that I do not get the ComboBox to properly find the user associated with the ID.

 

At the moment, using {DisplayName:ThisItem.ManagerFName&" "& ThisItem.ManagerLName} in the DefaultSelectedItems property displays the name, but doesn't really set the ComboBox to the record, as the fields I have showing the User Email and First and Last Name that pull their data from the Selected record in the ComboBox are empty. This tells me I am not setting the ComboBox DefaultSelectedItems to the ID value from the saved record.

 

By the way, I am only allowing one selected record, not MultiSelect. I hope that makes what I am trying to do a bit clearer. Thank you for all the time to help!

Highlighted

@dBrand ,

The conundrum you have is that you are not saving the value you want in the combo box and if you display something else, when you do not change the box, it will try to save what you have there. I do not believe you can accomplish what you want to do in the combo box itself. You may be better off with a label in View mode visible and the combo box in Edit mode.

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Community Highlights

Community Highlights

Check out the Power Platform Community Highlights

Top Solution Authors
Top Kudoed Authors
Users online (11,878)