Include all containers except for one (or alternatively exclude only 1 container in a list)

I have use a single container at root level for all my projects called (unsurprisingly) /Projects. Within the projects container I have specific project types also as containers with names along the following lines

  • Workshops
  • Studies
  • Campaigns
  • Programmatics
  • Missions

To help me manage all the information I use a series of Agents which either query the whole /Projects container or a specific subcontainer. These can be used to give me a list my latest notes, on-going studies etc…

My question is that sometimes I would like to query all subcontainers except for 1 of them. For queries that include /Projects the query is typically descendedFrom(/Projects) to locate all the notes descended from this container. A similar idiom applied to agent queries focused on the contents of each sub-container.

However, what if I would like to query all subcontainers except for say /Projects/Missions ? Sure I can write descendedFrom(/Projects/Workshops) & descendedFrom(/Projects/Studies) & etc.... I can also create a new attribute $IncludeInAgent and query on that as the expense of yet another specialised attribute.

It seems to me that the main information I have as a user is the container that I don’t want to include. Something like !descendedFrom(some container) doesn’t work as far as I can tell but would be a succinct way of expressing the idea.

isn’t a new attribute $DoNotIncludeAgent the way to go? Instead of a complex search, you just set the flag to one container?!

Testing quickly with a Projects container and 3 child containers (A, B and C), then the following seems to work to exclude Project B and its descendants.

descendedFrom("Projects") & $Name != "Project B" & !descendedFrom("Project B")

I don’t know if there’s a more idiomatic way of doing it through a search, sorry (though of course I agree that an attribute is probably a quicker way of doing it regularly).

Apologies if I’ve missed something.

How about:

$Container!="path of some container"

So for /Projects/Missions:

$Container!="/Projects/Missions"

Thanks - I didn’t realise that the negation operator ! could be applied to what is essentially a list of paths.

1 Like

That would work for the children of Missions. I assume that for additional sub levels of containers and notes the !descendedFrom() is required ?

I had to test it to be sure!

I did try it in a couple of other configurations (mainly changing the order of the three terms and clumping two together with brackets) and not all of them worked. Not sure why… The simplest version that worked was the one I’ve shown above: just the 3 basic criteria without any grouping, but you may have to play around to get the best configuration for what you want.

Hope it helps, anyway.

Apologies if over precise, that wasn’t the question asked! And, that’s not a snarky responce.

I see the question has already acquired 3 different answers all of which look plausible (I’ve not tested). What that shows is that there is no 'one right way. Also, my experience is time working out the real question is a saving. So if the answer doesn’t meet the question, clarify the question. Again, not critique, just leaning from experience. :slight_smile:

Definitely a misunderstanding as in my minds eye I was looking for solutions to query the full hierarchy of all subcontainers of /Projects except for one e.g. /Projects/Missions. Looking at the post it is stated implicitly in the last two paragraphs in the examples/initial solutions I suggest rather than explicitly.

I agree - the solutions proposed all look like good ones for my particular problem and I’ve learned that you can put a NOT operator in front of action code such as descendedFrom().

1 Like