I would like to edit some of my key attribute (list) values across all uses of a given user KA. Is there a way to do batch edits so that I don’t have to edit each instance of a given KA value? TIA.
Not sure if I understood correctly: if you want to edit KA values for multiple notes you can quickstamp them (CMD+2, properties inspector, quickstamp): just input the KA (or any attribute) into the search, choose the value, then apply; if you insert ‘$KeyAttributes’ into the search box you can even change the KA themselves at once for all selected notes.
Yes, use an agent. Note that with a list-based attribute such as List or Set types ($KeyAttributes is Set-type) you can’t use the
== equality test but you can use
.icontains(). In a list setting the latter two essentially act as if an equality test for complete discrete list value: see more.
So, make a user String attribute MyStringA. Create your agent and set $MyString and $MyStringA as Key Attributes. Set the agents query to:
Now, set the KA value you want to edit in the agent’s $MyString. The agent should list all notes with KA using that value.
If you are able to narrow the query, for instance via a prototype match, add that to the start of the query. Here, we’ll only do the above test in notes using the “Person” prototype:
$Prototype=="Person" & $KeyAttributes.contains($MyString(agent))
Now, in the agent action we want to add/change/remove an item. To add $Badge to KAs in aliased notesn, set the agent’s $MyStringA to “Badge” and use this action:
$KeyAttributes = $KeyAttributes + $MyStringA(agent);
Note that KeyAttributes stores the text names of attributes without a prefix. Now, if you wanted to remove $Badge from KAs, set the agent’s $MyStringA to “Badge” and use this action:
$KeyAttributes = $KeyAttributes - $MyStringA(agent);
Lastly to replace $Badge with $Border, set the agent’s $MyString to “Badge” and $MyStringA to “Border”. Now use action:
$KeyAttributes = $KeyAttributes + $MyStringA(agent); $KeyAttributes = $KeyAttributes - $MyString(agent);
Notice, for caution we do the removal last as it is the value we are using for the agent query. That said, the agent query doesn’t update until after the action has run. However, using the ordering as above removes the possibility of sawing through the branch you are sitting upon.
Thanks, @mwra. As always, I appreciate your attention and patience!