cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
JamFestival
Helper I
Helper I

The correct way of setting up a Office365.SearchUsers combobox in an EDIT form

Hi,

I am using a Combobox in a datacard to add an internal client to a record within an edit form (I have a separate 'new' form with the combobox and that works fine).
Try as I might, I cannot get it to work. When navigating from the gallery, it obviously needs to be blank if the client field in the record being edited is blank, and if not, pre-select the existing user in the field, then allow me to edit it. All the variations I have tried within the 'DefaultSelectedItems' property, it either pulls in the first entry from our Active Directory if the existing field is blank, or if I try to avoid that, I cannot use the combobox to search a user.
As this is the most common use of a combobox, I'm assuming others are managing to do this. Would anyone please share how it's done?
Thanks.

1 ACCEPTED SOLUTION

Accepted Solutions
JamFestival
Helper I
Helper I

Thanks to @v-bofeng-msft for the essential advice.

 

The key factor that I was missing was ensuring that the form 'knew' that the field was empty prior to navigating to the edit screen. 
Here's what worked:
1. On the gallery's screen, I added this to the 'OnVisible' property:

 

Set(
    varNoClient2,
    false
)

 

2. On the edit icon in the gallery, my 'On Select' property:

 

 

//Select the record, and set the variable to true if the ID field is blank, then navigate to the edit screen
Select(Parent);
If(IsBlank(Gallery1.Selected.CO2_ID)=true,Set(varNoClient2,true));
Navigate('Edit Record',ScreenTransition.Cover)

 

 

3. In the edit screen, in the edit form, in the combobox, I set the 'DefaultSelectedItems' to:

 

 

//Use the ID field to populate, but only if the variable is false
If(varNoClient2=false,
   Office365Users.SearchUser({searchTerm:ThisItem.CO2_ID}),
   Blank()
)

 

 

 

View solution in original post

1 REPLY 1
JamFestival
Helper I
Helper I

Thanks to @v-bofeng-msft for the essential advice.

 

The key factor that I was missing was ensuring that the form 'knew' that the field was empty prior to navigating to the edit screen. 
Here's what worked:
1. On the gallery's screen, I added this to the 'OnVisible' property:

 

Set(
    varNoClient2,
    false
)

 

2. On the edit icon in the gallery, my 'On Select' property:

 

 

//Select the record, and set the variable to true if the ID field is blank, then navigate to the edit screen
Select(Parent);
If(IsBlank(Gallery1.Selected.CO2_ID)=true,Set(varNoClient2,true));
Navigate('Edit Record',ScreenTransition.Cover)

 

 

3. In the edit screen, in the edit form, in the combobox, I set the 'DefaultSelectedItems' to:

 

 

//Use the ID field to populate, but only if the variable is false
If(varNoClient2=false,
   Office365Users.SearchUser({searchTerm:ThisItem.CO2_ID}),
   Blank()
)

 

 

 

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on June 15, 2022 at 8am PDT.

PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

Top Solution Authors
Top Kudoed Authors
Users online (1,856)