I have a container serving as a timeline for my classes. I have several prototypes that correspond roughly to the bands of the timeline, and I’d like notes to be assigned to the right timeline band automatically.
This is the action code I’ve tried. I currently have it in the container’s $Edict (and I assume the principle would be the same if I used $OnAdd instead):
if ("Activity;Assessment;Resource;Problem".includes($Prototype)) {
$TimelineBand = 2;
} else {
if ("Learning goal;Standard".includes($Prototype)) {
$TimelineBand = 1;
}
}
However, it doesn’t seem to be taking effect. I’ve tried restarting Tinderbox (since I’ve read that Edicts run upon opening the document), and edicts are enabled on the container note.
Do I have something wrong with the action code, or is there something else I’m missing?
$OnAdd actions apply to a container’s children. $Edict actions apply to the container itself. So this action would only change the $TimelineBand of the container, not any of its children.
Yes; after writing that last post, I discovered this doesn’t seem to work consistently for me; AFAICT, creating a new note and setting $Prototype does set $TimelineBand, but if (for example) I change $Prototype again, $TimelineBand does not change accordingly.
Huh, I guess $TimelineBand is an intrinsic attribute.
In that case, @jxxmxxj, setting it in the prototype won’t work, since intrinsic attributes (such as $Width, $Container, and $TimelineBand, evidently) are not inherited from prototypes. Easiest would probably be to set it with an Edict in the prototype. I.e., add this Edict to the “Learning goal” and “Standard” prototypes:
$TimelineBand=1
And $TimelineBand=2 to the Edicts of the “Activity”, “Assessment”, “Resource”, and “Problem” prototypes.
Or you could use an agent, but if you do use an agent, make sure that you specify that you wish to set the timeline band in the original note, like this:
$TimelineBand(original) = 1
otherwise you will only set the timeline band of the alias (since aliases do not share intrinsic attributes with their original notes).
For something like this that will change very rarely, I would use an edict rather than a rule. Rules update very frequently, and are wasteful unless you need those frequent updates.