OnAdd doesn’t work by selecting things. Rather it runs once, and once only on any item (note or container note—but not a containers’s contents) that is created in or dragged/moved into the container with the $OnAdd code.
So if you add a container of notes into another containers, the latter’s OnAdd will only act on the new container and not on its contents. so, you need to rethink your approach. Perhaps get the OnAdd to set a user boolean $NeedsRenaming to true
:
$NeedsRenaming = true;
Now an agent can search for notes inside containers where $NeedsRenaming is set and then run an action:
$Text=$Name;
$Name=$Name.words(11);
$IsRenamed=true; // uses boolean user attribute
…which takes a long title and copies it to the note’s text before truncating the title to use only the first 11 words of the original title. It sets a boolean to show the note is renamed. A different query can then find containers where $NeedsRenaming but all notes are renamed and unset the the container’s boolean.
The agent doing the renaming uses this action:
$Text=$Name;
$Name=$Name.words(11);
$IsRenamed=true; // uses boolean user attribute
if($Container(original).contains("REN_ART")){
$Prototype="pArticle";
};
if($Container(original).contains("REN_DOC")){
$Prototype="pDocument";
};
if($Container(original).contains("REN_ART")){
$Prototype="pInterview';
};
Note that as we’re using an agent, you are acting on an alias whose $Container is the agent so we need to test $Container(original).contains...
and not $Container.contains...
Does that help?