The issue is not the overall syntax but your incorrect referencing of the
$location. As written, you are asking Tinderbox to test each note using the tested note’s
$location value. What you actually want is to test using the agent’s value for
$location. A special ‘agent’ designator is provided for this purpose and which can be using in either/both the agent query or agent action to refer to an attribute value in the agent and not the tested note.
If I use this query (tested in v9.1.0), following your existing layout:
I get the desired match.
A tip. In a test with a few notes the order of terms doesn’t matter. But
.contains() use regular expression matches with involve more (CPU) effort than other query terms. So, it is a good idea to place them last in the query. The works well with a general premise of writing multi-term queries so each term reduces the number of queries for the next term.
This is is a better version of the query above:
descendedFrom($location(agent)) & $Name.icontains("grouch")
I’ve added spaces around the
& AND join for clarity but they aren’t needed as Tinderbox ignores such whitespace.
Also see my article on Controlling Agent Update Cycle Time at the section on Making Agents More Efficient, which discusses the latter can be bookmarked for reference until the optimal ordering of query terms feels natural.
If any of this is not clear, please ask!