How to dynamically filter a multiselect field

How to dynamically filter a multiselect field

The method of filtering a multi-select field is very similar to dynamically filtering single-select dropdowns as described here. However, the problem with filtering a multiselect is that when you edit the record the filtered list is not shown and all the checkbox options given in edit mode are listed instead. Filtering it again causes the selected options for the record to be lost. The workaround is to add a script in the on Edit>on Load task that saves the selected options, filters the list and sets the selection back again.

1. Create the multiselect with dummy options, note that when selections are saved in the field those options will be saved automatically
2. Setup dynamic filtering in the same way as for dropdown fields
3. In the on Add>on Edit action of the form write the following code:

      //first save the checked options in the Course field
      x = List();
      for each opt in input.Courses
      {
            x.add(opt);
      }

      //clear it and filter it so that it shows the correct courses for the selected School

      clear Courses;
      rec  =  CourseForm [Criteria == input.School];
      Courses:ui.add(rec.Courses.getall());

      //set the previously selected options again
      for each y in x
      {
            Courses.select(y);
      }

    • Related Articles

    • How can I make a field to be "required" dynamically?

      Assume you have a radio button field named Field1 in your form with values "Yes"/ "No" and you want Field2 to be required only if the value ofField1 is "Yes". To achieve the given scenario, add the given script to Form Actions -> On add -> ...
    • How do I set a custom filter to search for records where a certain field is not empty. For example, "Field does not contain [blank]"

      If the field is of type "Text", you can set the Filter condition in the Free flow scripting of the View as given below and Save the script. Specify the required 'FilterName" and the "Fieldname". "FilterName" : (Fieldname not equal to "") If the field ...
    • Apply Filter

      To apply filter: 1. Select the column or range of cells to be filtered. 2. Click Data> Filter or use the Filter icon  from Toolbar or right click on the selected range and select Filter from the context menu. 3. Choose the required filtering ...
    • How do I Filter Views based on Date Criteria?

      Show records that expires in the next seven days You can use the following criteria in your view to fetch records ending in the next 7 days, based on the Expiry date in the form. In the sample code given below, Expiry is the name of the date field in ...
    • Filter users

      Advanced filters can be used to generate a list of specific users, and perform bulk actions on them.  Advanced filter  Sign in to the Zoho One Admin Panel. Click on Users. Click  in the top-right corner. Set the filtering criteria, then click Apply.