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.
Solved! Go to Solution.
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()
)
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()
)
User | Count |
---|---|
260 | |
123 | |
99 | |
48 | |
43 |