Power Community

Power Community

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

image

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

{Value: Coalesce(cbData.SearchText, cbData.Selected.Value)}

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.

If(
   Len(cbData.SearchText) > 0,
   ForAll(
      Ungroup(
         Table(
            {Data: Table({Value: cbData.SearchText})},
            {Data: ThisItem.MultiField}
         ),
         "Data"
      ) As aAdd,
      {Value: aAdd.Value}
   ),
   cbData.SelectedItems
)

This post was originally published on this site

- Advertisement -spot_img

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisement - Advertisement

Latest News

Microsoft named a Leader in the 2024 Gartner® Magic Quadrant™ for Analytics and BI Platforms

We are thrilled to announce that, for the seventeenth consecutive year, Microsoft has been positioned as a Leader in...

More Articles Like This

- Advertisement -spot_img