cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
geneZebra
Resolver II
Resolver II

sharing an easy way to add an item on the fly to a comboBox based on a data source

Note: I tried to post to best practices area but could not see how to label it for the post to go through. If this is in the wrong forum, let me know how to properly post in the correct forum. Thanks.

 

I struggled for some time on how to add a "Create New" and other options to a comboBox's dropdown list. I did not want to create another global collection in application especially since the scope of this entry is only needed in the comobox.

 

I could not really find a way to do this without getting all sorts of data type mismatch errors so if anyone can find a cleaner solution please share.

 

The code below is for the items property in the comboBox. The Split function creates the lists of items from a string. based on a text deliminator. To add the "*Create New" option or any other option to the list, that option is appended to the string along with the deliminator used by Split.  

 

The string used by Split, is a text dump of the list from a table via a function called Concat. I use Distinct and filter to only list unique entries that meet a criteria but Concat creates a string based on the field name and a deliminator. Since I am using Distinct, "Result" is the field name that Concat works on. The key to this solution is to use the same text deliminator by both Split and Concat. That way when Spit runs, it just sees the newly added options as values using the same deliminator.


items: 
Split( "*Create New|" &
        Concat(Distinct(Filter(Budgets,Value(ID) <> 0), OwnerName) ,Result & "|")
        , "|"
)

1 ACCEPTED SOLUTION

Accepted Solutions
v-xida-msft
Community Support
Community Support

Hi @geneZebra ,

Thanks for your sharing. It is an easy way to add any extra options within a ComboBox.Smiley Very Happy

 

I would also share your solution to my team memebers.

 

Best regards,

Community Support Team _ Kris Dai
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

1 REPLY 1
v-xida-msft
Community Support
Community Support

Hi @geneZebra ,

Thanks for your sharing. It is an easy way to add any extra options within a ComboBox.Smiley Very Happy

 

I would also share your solution to my team memebers.

 

Best regards,

Community Support Team _ Kris Dai
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

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Power Apps June 2021

June Power Apps Community Call

Did you miss the call? Check out the recording here!

Top Solution Authors
Top Kudoed Authors
Users online (13,664)