Agent to find a single tag when multiple tags are assigned to a note

Hi All,

I just created an agent to find all notes that have a particular tag:

$Tags=="curricular theme"

It works when a note has only that tag assigned but is not finding other notes that have the “curricular theme” tag in addition to other tags.

For instance the agent did not find a note with:

“control;curricular theme” as the tags.

I tried putting curricular theme as the first tag as in “curricular theme;testtag” but that did not make a difference.

Is this an issue in the way I am including tags, an issue with the agent, or some other issue?

Thanks for any assistance!

To test a multi-value attribute (e.g. a List or Set) you need to use the .contains() or .icontains() operator.

Why? Well == is a exact match to the string value of $Tags and if ‘curricular theme’ is the only value the match works. But once the second term is added, == is trying to match all of ‘curricular theme;testtag’, with the results you encounter. So, you want a query term like:

$Tags.contains("curricular theme")

This will work whether your match is the only value or one of many for that tag/note.

[later]
This differential need for differing syntax for a ‘value is’ test is explained in my notes on ==. See also .contains() and .icontains().

Thanks, @mwra! This is very helpful and the explanation makes a lot of sense to me. I tried out .icontains and it worked perfectly. Thank you!