Filter: exclude values if they exist in a field

In my Gift Ideas notebook I’m storing the following:

  • Tagged person are the persons I’m planning to give gifts to
  • Tagged gift are the gifts to be given, they have two fields:
    • to-gift: a list of possible person gift receivers
    • already-gifted: a list of persons who already got this gift

On each gift I’m displaying two <$select> widgets, one for each list to-gift and already-gifted, for example:

<$select field="to-gift" multiple size="10">
  <$list filter='[tag[person]]'>
    <option><$view field='title'/></option>
  </$list>
</$select>

From each of these <$select> widgets I want to exclude persons found in the other list. If Person A is in the already-gifted list, they shouldn’t appear in the available to-gift options and vice versa.

Something like [tag[person] -[already-gifted]] but correct :sweat_smile:

Because already-gifted is a field that contains a list, you want to use the enlist[] operator, like this:

<$list filter='[tag[person]] -[enlist{!!already-gifted}]'>

enjoy,
-e

3 Likes

Thank you, that was exactly what was missing.