Qualifying a Display Expression

Close…
In this case you’ll want to replace $ChildCount with $MyNumber, as $MyNumber now holds the count without folders being counted, whereas $ChildCount counts all Children.

So, in this context you’ll say:

$MyNumber=collect_if(descendants,$Prototype!="Folder",$Name).count;
$DisplayExpressionCache=$Name+" ["+$MyNumber+"]";

I just realized there were some smart quotes in there, and that might account for the problem. Ok, so now the code is:

$MyNumber=collect_if(descendants,$Prototype!="Folder",$Name).count;
$DisplayExpressionCache=$Name+" ["+$MyNumber+"]";

Does this belong in the Rules or Edict box?

Strangely, I removed the “Folder” prototype add-on from the notes container, but the folder badge remains intact. Anyway, I reapplied the “Folder” prototype add-on with the corrected code, but it’s still not generating any number. Any other suggestions?

Thanks!

Looks good.

Action code can be in a Rule or an Edict. Rules run continuously, Edicts run periodically, that is the only difference. I prefer Display Expressions to be in Edicts because I use a lot of them and I don’t need the instantaneous update.

I don’t recall there being an $OnAdd for the prototypes, but that does no matter. An $OnAdd has nothing to do with a badge. Removing that will not remove the badge. Now, if you change a note’s prototype that could affect the badge. More on this later.

No other changes. If it is still not working, I bet you have a severed inheritance issue. As noted, I’ll record a training on this later.

I think I follow you, and will try using the prototype with a fresh data set. I should hasten to add that I’m working in Outline view, not maps — and that’s why I’m applying the Folder prototype to note containers as an add-on. FWIW…

Thanks again!

Important to note, views are just views, different lens for analyzing and working with your notes. Views have no effect on action code. Action code works the same way in map view, or outline view. If you have an $OnAdd function running, it will apply just the same whether or not you’re in map view or outline view.

1 Like

Thanks. I might be using the wrong phrase to describe what I’m trying to do.

Here’s a dummy set up…


…and the “add on” action I was referencing, in which I’m right-clicking the Note Container folder, and then selection the Folder prototype…

Screen Shot 2021-05-12 at 9.19.50 AM

Ok, I see the problem. :slight_smile:

Look at your action code, it says $Prototype!="Folder".

Look at the name of your prototype “Folder prototype”. Your action code is looking for the prototype “Folder”. This does not exist. What exists is “Folder prototype”. To fix this, change the spelling of “Folder prototype” to “Folder”.

Remember, note names are not unique, i.e. you can have multiple notes named “Folder”. A best practice is to ensure your prototypes always have a unique name. I and others accomplish this by appending a lowercase “p” to prototype names, e.g. “pFolder”. So, to modify the above, I would change your prototype name to “pFolder” and your action code to reference “pFolder”.

1 Like

Thanks so much. I actually did exactly what you suggested in the original Tbx file, but not in in the dummy. So, I doubt that’s the actual problem in this case. I’ll try setting it all up again in a clean file, and will report back… Thanks again.

1 Like

Ok, I’ve good news and bad news…

I’ve changed the name of the prototype to “pFolderCount,” and applied it to a folder in a fresh dataset.

The good news is that prototype does produce a number next to the folder.

The bad news is that it’s also counting the agents in the folders (i.e., what we called the “note container” – which really contains agents, and notes that fall under those agents), so the number counts are inaccurate.

How would you suggest I fix this?

Thanks!

First, good job on your progress.

Can you do two things?

  1. Give me a screenshot of your outline view
  2. Give me a screenshot of your pFoldercount edict

It will be hard to debug without seeing what’s going on.

I’m happy to do that for you, of course. But what do you want me to capture in my outline view? Just want to make sure it matches what you’re seeking. Thanks!

I am looking for this:

Here’s the code for the edict…

Screen Shot 2021-05-12 at 10.25.25 PM

…sending the other stuff to you on the other side…

Hi @jprint714 Thanks for the image above and DMing your private folder structure.

I see the issue. the action code in your Edict is fine. The problem is that you’ve not applied the prototype to the child containers in your note. Here is an example based on a screenshot from my demo file.

See how the Child container 1 does not have the pFolder prototype applied, so the Edict is seeing is as a note and counting it. Remember, through the Edict, we are telling Tidnerbox to count all the notes that are NOT pFolder. We do this with the $Prototype!= expression. != means does not equal.

To fix this, rt. mouse click on the icon to the left of the badge selector (the little plus). You’ll get a dropdown and you can select your folder prototype. Once you’ve applied the folder prototype, all should be good.

2 Likes

Wow. Thanks so much! Such an easy fix… I applied to my existing dataset, and it worked – though on occasion it didn’t work completely. I’m going to create a fresh database, apply pFolderCounter to all of the folders, and see how it works with newly-imported data. I’ll report back if I’ve got any problems / question. Thanks so much!

I’ve got a super quick question since we’re on the topic of folders, agents, prototypes, etc… If I want to apply a badge (e.g., a person badge) to all notes that are collected by a query agent (e.g., and agent named “People”), would I have to use a Prototype to do that? Or is there another, simpler way to do that?

Thank you again for all of your generous help! I really do appreciate it…

Let’s suppose you want to give all the notes found by the agent People a badge image

We could do this with the agent action

$Badge="user";

Or, if all the notes this agent gathers should share the same prototype — maybe the prototype Person – we could add the badge to the prototype and inherit it from the prototype. In that case, the agent’s action would set the prototype:

$Prototype="Person";

If some of these notes already have badges, and we want the new badge to replace the old, we remove the old badge first:

$Badge=; $Prototype="Person";

There are two approaches I would recommend, similar to @eastgage suggestion.

  1. Run an Agent Query and then apply an Agent Action $Badge=“person”;
  2. Run an Agent Query and then apply an Agent Action, $Prototype=“Person”;

REMEMBER: With Tinderbox, if there is one way to do something there is probably 10 or more. Which path you choose all depends on your context.


Here is a sample file for you. That shows the two approaches. To demonstrate this, you can create a note and just drop it into the People 1 or People 2 containers and you’ll see the respective agents automatically search inside the container and then apply the action.

TBX L - Using and agent to assign a badge or prorotype.tbx (113.0 KB)

Of course, the actually strategy you apply all depends on where your notes are, what criteria you’ll search on, etc.

Enjoy. Let me know if you have any questions.

Remember, since it is an edict if may take a few seconds or minutes to run and update the notes. Sometimes you simply need to click on the note to force a refresh.

Thank you so much for all of your help with this, @satikusala & @eastgate! So, here’s my situation… I’ve got a process in which I’m importing notes into a Tinderbox database, and then my query agents designate where my notes appear (as alias, since they’re almost all multi-valued).

So, I rarely keep track of instances where a note would fall into, say, People and Timeline categories – and would be marked with a People & Clock badge (which are so far the only two badges I’m using, since those visual markers can be useful for my research).

Anyway, I’m mentioning all of this to explain that there will be instance where I’ve got notes that would have competing badges, and so… What kind of approach would work best w/ prototypes, code, etc. under this scenario?

Thanks again!

Few thoughts.

  1. I would start using attributes. For example, you could have a $Type attribute with its value set to person or event. That way the action code could set the badge based on the value of the attribute and not the location of the note.
  2. I would a) create a new badge icon that illustrated both badge elements for multi-value types (probably too complicated), better yet b) use the badge in combination with another visual. e.g. $Color or $Flag. This second visual can be set by the value in a second attribute.

It is hard to be perspective at this point as the prescription is dependent on your personal process.