cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
simms7400
Post Prodigy
Post Prodigy

Multi-Select ComboBox - how to read back in values?

Hi Folks -

 

I have a SP table populated with my Master Data Elements called "rdInvestments". In that tables, are additional columns (attributes) for each data element. One of them is "OrphanDesignation" and it's a text field.

 

Therefore, I have added that field to my EditForm and it's called "Regulatory Designation".  Now comes the tricky part.  I added a multi select ComboBox (ComboBox4) to this data card and included all of the applicable choices in the Items property.

card.jpg

 

Reg.jpg

 

Next, my target application requires the values to be delimited with a "comma" therefore in DataCardValue78, I have this formula and it's working great!

 

Mid(Concat(ComboBox4.SelectedItems, Value & ", "), 1, Len(Concat(ComboBox4.SelectedItems, Value & ", ")) - 2)

This works great for a net new data element and apply these Regulatory Designation values.  Howevever, when an end user wants to make a change request and change Regulatory Designation values that were previously submitted, they are obviously not showing up in the EditForm.

 

Is there a way I can read back in the values of "Reglaroty Designation" into the CombBox4? this poses two isseus becaiuse 1, the ComboBox is not directly connected to the SP list and 2, I think that fact they are comma delimited wont allow them to be read back into the ComboBox (if they could).

 

As an example, if an end user intiaited a change request on the this data element (PFI-000124-00162), I need to read back the Regularoty Designation values, highlighted:

save.jpg

 

Is there a way to achedive this?  Thank you!

 

 

 

 

f

1 ACCEPTED SOLUTION

Accepted Solutions
RandyHayes
Super User
Super User

@simms7400 

Yes, this is fairly easy to implement.  In your DataCardValue78 DefaultSelectedItems property, set the formula to the following:

   RenameColumns(Split(ThisItem.RegulatoryDesignation, ","), "Result", "Value")

This will split the value in the field by its commas and return a table with a Result column (that's what Spilt does).  The trick is that we just need to rename that column to "Value" because that's what the ComboBox wants (based on your Items property).

 

I hope that is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

9 REPLIES 9
RandyHayes
Super User
Super User

@simms7400 

Yes, this is fairly easy to implement.  In your DataCardValue78 DefaultSelectedItems property, set the formula to the following:

   RenameColumns(Split(ThisItem.RegulatoryDesignation, ","), "Result", "Value")

This will split the value in the field by its commas and return a table with a Result column (that's what Spilt does).  The trick is that we just need to rename that column to "Value" because that's what the ComboBox wants (based on your Items property).

 

I hope that is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

@RandyHayes 


Thank you! So upon reading your suggestion, I'm noticed something. DataCardValue78 doesn't have a "DefaultSelectedItems" property, only my ComboBox4 does.   Did you mean to put it there? If so, when I do put it there, it works great!

 

As usual, thank you so much, Randy. HAve a great rest of your weekend!

@simms7400 

Oops...yep, just noticed on the picture - yes, ComboBox4

Sorry about the confusion. 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Thank you! I've been puzzling how to do this for a while. This is the first solution thats worked for me. In the update property I got away with using Concat(ComboBox2.SelectedItems,Title,", ")

 

Gareth

Thanks for the solution, but i can't seem to get it to work as i want it to. 

 

I get all the values shown in the DefaultSelectedItems property however the combobox is still always empty. The values are never actually selected by default.

 

Is there something I'm missing?

 

Asaf.

@RandyHayesI am using SQL DB to store selections from the Combobox using Concat(Combobox_Name.SelectedItems,ColA, ","). ColA is fetched from another table which is already liked to the Combobox. 

 

My form has multiple Combobox, some may need to be edited. So, I am reading the stored data from DB using the method you proposed. 

 

After editing, when I am sending back the data, it's writing only the newly created data but all the Combobox in which no change was made, the data for them is deleted from DB.

 

Ideally, I realized the Concat function is not able to read the values from the Combobox (referring to the values that are being read from the DB to Combobox). Any solution for this?

 

@asafweis I am facing the same problem. I am getting them shown in the DefaultSelectedItems property, but the Concat results of the Combobox is always empty. Any Solutions?

WalterW
Advocate II
Advocate II

Took all morning trying to figure this out. Turns out with using Concat on multiple values, when you bring the values back in, a ", " (comma space) is also brought back in as a selected item. Once I removed that ", " or "," at the end, my values started to appear. That comma at the end it what's messing things up. Check out the below article at the "Trimming the End" section. It's a great explanation for what is happening. You will want to adjust the Concat argument that writes to SharePoint.

 

Left( Concat( Products, Name & ", " ),

Len( Concat( Products, Name & ", " ) ) - 2 )

 

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-concatenate

RandyHayes
Super User
Super User

@WalterW 

Also consider to shorten your double evaluation of the Concat function to use:

With({_c: Concat( Products, Name & ", " )},
    Left(_c, Len(_c) - 2)
)

 

However, even with the above for storing a concat'ed string, it is always best to filter the split of the above to make sure you are not getting blank values.

Ex.

Filter(
    Split(<theConcatedString>, ", "),
    !IsBlank(Result)
)

This will ensure that if there are any trailing separators, then they will be excluded from any Items properties.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Power Apps Community Call Jan. 2022 768x460.png

Power Apps Community Call

Please join us on Wednesday, January 19th, at 8a PDT. Come and learn from our amazing speakers!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

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