Yes, that would not work for the reason explained here: when working on a list (List or Set type), the .contains/.icontains operators can only match entire list values. Don’t feel bad - I was only reminded of this on checking aTbRef after testing your comma query and confirming it didn’t work!
Consider my test with the $Mots with contents “ant;bee,cow”, i.e. it holds two values ‘ant’ and ‘bee,cow’. Thus $Mots.contains()
can only match ‘ant’ or ‘bee,cow’. A single character cannot be matched.
The answer to using an agent is to use some other method to gather the notes. For instance the query $Mots
will gather all notes that have a value for $Mots. Now we can run the stamp code above as the agent action.
The action will act on all aliases in the agent. This is not a problem as the action only replaces unwanted commas. Notes matching the query that have no such commas are not affected.
I hope that makes sense - if not, do ask.