cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Hoc
Microsoft
Microsoft

Add new item dynamically in Combo box

I want the user be able to enter a free form text in Combobox and if it is not in the list, add as a new item. For example, item 16 does not exist so this Search box will be acting as a New input box as well. Let's say if I hit enter or trigger via another button, it should add the new Item 16:

 

Screen Shot 2020-04-18 at 11.23.59 PM.png

Is there a way to do this or some workaround?

The only thing I can think of is to add a Textbox overlay on top of the Search box and "mirror" everything down in Search box. But if result=0, then add into the list.

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
v-yutliu-msft
Community Support
Community Support

Hi @Hoc ,

Do you want to add a new item if there's no matching text with the text you enter in this combo box?

If so, you could use ComboBox1.SearchText to represent the text entering in the combo box and use this to compare with the items in the combo box.

I've made a similar test for your reference:

1)set the combo box's Items:

list1
//my data source name, please replace with yours

2)set the combo box's OnSelect:

Set(var,ComboBox2.SearchText);
If(IsEmpty(Filter(list1,field1=var)),Patch(list1,Defaults(list1),{field1:var}))

Then if the text in the combo box has no matching text, it will create a new item with this value automatically.

 

Please notice that the combo box's OnSelect will not act when you are entering text in the combo box.

You need to firstly enter data in the combo box, then click the blank space, then click the combo box again, the onselect property will be triggered.

Like this:

420.gif

 

 

Best regards,

Community Support Team _ Phoebe Liu
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

8 REPLIES 8
eka24
Super User
Super User

It seem this functionality is not current available. You can add your voice to this already demanded Idea:
https://powerusers.microsoft.com/t5/Power-Apps-Ideas/Dropdown-control-allow-end-user-to-add-a-choice...

 

------------

If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

v-yutliu-msft
Community Support
Community Support

Hi @Hoc ,

Do you want to add a new item if there's no matching text with the text you enter in this combo box?

If so, you could use ComboBox1.SearchText to represent the text entering in the combo box and use this to compare with the items in the combo box.

I've made a similar test for your reference:

1)set the combo box's Items:

list1
//my data source name, please replace with yours

2)set the combo box's OnSelect:

Set(var,ComboBox2.SearchText);
If(IsEmpty(Filter(list1,field1=var)),Patch(list1,Defaults(list1),{field1:var}))

Then if the text in the combo box has no matching text, it will create a new item with this value automatically.

 

Please notice that the combo box's OnSelect will not act when you are entering text in the combo box.

You need to firstly enter data in the combo box, then click the blank space, then click the combo box again, the onselect property will be triggered.

Like this:

420.gif

 

 

Best regards,

Community Support Team _ Phoebe Liu
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

It works,
just IsEmpty is not enough, you need to also include && !IsBlank(var)

I'm not sure whether it will work or not, cause in the OnSelect event, the SearchText is not typed yet.

Do you guys have a work around on this issue?

Ricardo_Costa
Regular Visitor

I had the same issue and I solved it like this.

 

Datasource: SharePointList

 

In the combobox items property I put: Distinct(SharePointList,ColumnA).Result

 

In a save button OnSelect property I put this: Patch(SharePointList, Defaults(SharePointList),{ColumnA: If(IsBlank(combobox .Selected.Result), combobox .SearchText,combobox .Selected.Result))

 

With this, when you type a new item in the combobox, it'll inserted in the SP List and will be available next time in the combobox within one click

Anonymous
Not applicable

I don't understand why do we need a second combobox?

This solution has stopped working. 

 

Now when you click on the blank space, it will no longer append to the collection now. 

Powerplatform01
Post Patron
Post Patron

You can watch this video to resolve your issue

https://youtu.be/FQLYt0CsWZQ

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.

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