Allowing a user to add a non-listed value to a multi-value field

I have used cbData for the Combo Box and MultiField for the field name in these examples.

It is easy enough to allow a user to add a custom value to a single select Combo Box with a Data Card Update of


so it simply uses the SeachText if entered and nothing is selected from it (or uses the selection as normal).

But what about multi-select columns ?

One fundamental issue here is that the SearchText is only accessible/visible when there are no other items selected, but we want to retain what is there presently and add the new item, so one compromise is the user needs to delete existing items that come up with the DefaultSelectedItems, but we can still retain them and add the new one.

With all this in mind (and assuming the output of the Combo Box is .Value), the Update of the Data Card firsts tests for anything in the SearchText and if empty writes back the “normal” SelectedItems Table. If there is data present in the SearchText when the Form is submitted, a Table is constructed combining this value with what is already saved in the data source field and this Table is written to the field.

   Len(cbData.SearchText) > 0,
            {Data: Table({Value: cbData.SearchText})},
            {Data: ThisItem.MultiField}
      ) As _Add,
      {Value: _Add.Value}

Leave a Reply

Your email address will not be published. Required fields are marked *