web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / How to add a new item ...
Power Apps
Answered

How to add a new item to a ComboBox

(0) ShareShare
ReportReport
Posted on by 514
I would like to type in and add a new value into a ComboBox.
It does not seem possible to type anything into a ComboBox.
How could I do this?

Currently I am reading data from a SharePoint list into a collection which is then used as the data source for the ComboBox.
To add a new value, I am thinking I would need to add the value into a text box and patch this data to the list. Then refresh the datasource, read to the collection and re-bind to the ComboBox to show the new value.
How to ensure I am not adding a duplicate also?

Trying to add it to the collection and then identify & pull this new value out and add it to the list could get complex.

Any help/code appreciated.

Thank you
Categories:
I have the same question (0)
  • mdevaney Profile Picture
    29,989 Moderator on at

    @sienna28 

    Typing a new value to add into a ComboBox is complicated.  The reason is you are supplying a single value but  a ComboBox is populated by records which contains multiple values.  The question is, how do you intended to fill-in those other values assuming you have more than 1 column in your list. 

     

    You have the right idea how to approach adding it.  Put code like this in the OnSelect property of your button.  This assumes the column you are adding information to is plain-text.

     

    Patch(
     your_datasource_name,
     Defaults(your_datasource_name),
     {ColumnName1: TextInput1.Text}
    )

     

    To ensure you are not adding a duplicate you could include this check.

     

    If(
     IsBlank(LookUp(your_datasource_name, ColumnName1 = TextInput1.Text)),
     Patch(
     your_datasource_name,
     Defaults(your_datasource_name),
     {ColumnName1: TextInput1.Text}
     )
    )

     

    Note: please replace all references with your own control names and SharePoint column names.

     

    ---
    Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

  • sienna28 Profile Picture
    514 on at

    Thanks for the reply.

     

    I just wanted to ask if this would work in a form.

    I know a form limits to controls from the data source so I wondered if it was possible to add a text box (to enter new items) to the form?

     

    I could just patch all control values and not use a form at all, but wanted to know if your solution could work in my form environment.

     

    The other issue is how to get the newly saved value as the selected item in the ComboBox?

    I was thinking of saving the item to a context variable, but how to get it to display as the chosen item?

     

    Thanks

  • mdevaney Profile Picture
    29,989 Moderator on at

    @sienna28 

    Yes, this could work in a form.

     

    To get the new values to appear in the ComboBox you could simply Refresh the datasource.

    Refresh(your_datasource_name)

     

    ---
    Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

  • sienna28 Profile Picture
    514 on at

    Thanks - I meant how to get the new value to appear as the selected one.

  • Verified answer
    mdevaney Profile Picture
    29,989 Moderator on at

    @sienna28 

    Change your code in the OnSelect property of your "Add Option" button.

     

    Set(newOption, 
     If(
     IsBlank(LookUp(your_datasource_name, ColumnName1 = TextInput1.Text)),
     Patch(
     your_datasource_name,
     Defaults(your_datasource_name),
     {ColumnName1: TextInput1.Text}
     )
     )
    )

     

    Then put this code in the DefaultSelectedItems property of your ComboBox

     

    LookUp(your_datasource_name, ID = newOption.ID)

     

    This example assumes your AllowMultipleSelections setting is.

     

    false

     

    ---
    Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

  • sienna28 Profile Picture
    514 on at

    Thanks - it all seems to work except the last part of defaulting the ComboBox to the added item.

     

  • sienna28 Profile Picture
    514 on at

    Selected Items property seemed to do it.

     

    Thanks

  • micsak Profile Picture
    2 on at

    Hi,

     

    I have similar problem:

    I have 2 share point lists (Invoices and Suppliers) and I'm working on power app of 1st list. In this power app I have 2 forms.

    on the 1st one has source of the 1st list (Invoices) where I enter suppliers from a drop list . When I want to add a new supplier, I have a button to navigate to the 2nd form with data source of 2nd list (suppliers)

    The problem is starting when I enter a new supplier (within 2nd form) and when I save the supplier record, I navigate back to 1st form but drop list is not updated with the new supplier.

    I tried the above with negative results. Could you assist me ?

     

     

    micsak_0-1605951691798.png

     

    micsak_1-1605951727835.png

     

     

  • astrontelstar Profile Picture
    287 on at

    I want to do this very thing.  Did you figure it out?

  • Aleksandra1 Profile Picture
    254 on at

    Hello,  can you help me? I have a collection which looks like this:

    Collect(
    ErrorCodes,
       "SOX-DOC",
       "QA-EU",
       "QA-CON"
    ); 

    I need to add a button for user, which will add a new values to a combobox. As I see in a Lookup function you have 

    ColumnName1 = TextInput1.Text

    , but I don't have column name in my collection. This is just list of error codes, how can I write a code for this case?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 721 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 320 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard