cancel
Showing results for 
Search instead for 
Did you mean: 
WarrenBelz

Dynamically filtered multi-select check boxes

Firstly, my thanks for the inspiration for this to @RezaDorrani in his great video.

I thought I would take this a couple of stages further with: -

  • Dynamic selection of the Checkbox content filtered off a (single select) Radio control.
  • Store the radio value in a Text field and the Checkboxes content in a Multi-Choice field.
  • Show and modify existing records including a change in the Radio Control content.
  • Continue to do all of this with SubmitForm() rather than any Patching.

A short example of it working is below

MultiBoxes.gif


Firstly, if the code seems a little over-complex, it is due to some refreshing issues I had in testing and the below seems to work as intended. It is based off a test list of PC devices, but can be applied to any similar structure.

As I mentioned, the primary radio control is stored in a Text field. For the secondary filtered item, create a Choice type column (as below I called mine MultiChoice) and ensure to check allow multiple selections.

MCField.jpg
The choices can be whatever you want - they will not be used - the "container" is needed to hold the data.

Gallery

Firstly, the gallery at the bottom of the demo is simply to select the record (as you would normally do). The number is the ID, but this is only to show the records present. The OnSelect of the gallery is

 

UpdateContext({varItem: ThisItem});
ClearCollect(
   colMulti,
   varItem.MultiChoice
)

You would also probably add a navigation to your screen here.

 

Form

The Item of the Form is: -

LookUp(
   Devices,
   ID = varItem.ID
)

and the OnSuccess

UpdateContext({varItem: Self.LastSubmit});
ClearCollect(
   colMulti,
   varItem.MultiChoice
)

 

Submit Button

The Submit Form button simply submits the Form.

SubmitForm(frmMultiBoxes)

 

 Radio Control

Default - shows the Text field stored in the data source in the relevant Radio button: -

varItem.Manufacturer

The Item selects the list of values you want to choose from: -

Sort(Manufacturers.Title,Title)

but will be whatever you need to show the primary list items. The Update of this Data Card - writes the selected item value to the Text field: -

rcManChoice.Selected.Title

The OnChange - important as if another value is selected, any stored values from the second field need to be cleared: -

Clear(colMulti)

 

Multi-Select Check Boxes

Now to the main item - firstly, the DataField of the card in my case is "MultiChoice" - the field created above (which is populated automatically if you insert the card normally).
Next, you need to delete all the controls out of the card and insert a blank Vertical gallery (this is well explained in Reza's video)
The Items of the gallery here are (note I found the pre-filter assisted refreshing): -

With(
   {
      wDevices: Devices,
      wMan: rcManChoice.Selected.Title
   },
   Filter(
      wDevices,
      ManufacturerName = wMan
   ).'Device Name'
)

You will have to apply the list and field names to your model. Next, insert a Check Box into the gallery with the following settings. Text (in my model - it will be your field name).

ThisItem.'Device Name'

The Default  -looks for instances of the value chosen in the Multi-Choice field in the data source: -

ThisItem.'Device Name' in colMulti.Value

Again this will be the name of the field you are displaying. Now set the WrapCount of the Gallery (mine is 4) to whatever fits with your field names. Lastly, the Update of the DataCard with the Gallery in it - writes the Collection to the Multi-Choice field in the data source: -

colMulti

This is a relatively complex process and requires the values above modified to your requirements, but if all steps are followed correctly, you should have a working model.

 

Comments

So for the choice field, if you want the items to be edited in the future as shown on reza’s video, with you adding choice fields that you want use, because I have a support list I am using, are you able to submit the items for that multi choice field back to share point and edit later in the form?

The values are stored in the multi-choice field which is a Table with one field Value which can be whatever list you want to store in it from time to time.

You can edit it after saving (if that is your question) and change the radio value, receiving and saving a new list of checkbox values.

@WarrenBelz @To add my multi choice field has the same values you used, which is a,b,c.

Whatever values you want (they will not be used) - you just need the multi-value capable structure to store the data in.