I created a Prototype with various On Add actions set to inherit the Attribute of the parent note, something like this:
$Authors=$Authors(parent);
I have a “Literature” container that uses that Prototype. Thus, each new note that is moved inside of it inherits these attributes.
My question is, how can I change the Action to inherit the value ONLY if the Attribute of the note I am moving inside the container is blank?
For example, I have a note somewhere else in the map with a preset Author value. I would like to keep the Author’s name when I move the note inside the container with the On Add action.
I think you need to use the |= operator instead of =. Essentially the logic of the former is as you describe. I’d put in an aTbRef link if i didn’t have the site in maintenance just know.
If in doubt about using, make a small test TBX - you’ll only need five or six notes to test: a prototype, the container and a note with and without $Authors data.
I’ve made a demo of both the |= and the if methods. They both have the same outcome. @PaulWaltersif method is easier to follow for the novice. Seeing seeing both methods together may remind us (me included) about the |= operator which is easily overlooked by those of us not steeped in logic syntax.
The |= operator is one of my favorite commands within Tinderbox. It has the multiple virtues of:
allowing you to streamline operations when usually a certain value or categorization will apply [like, $StartDate|=date(today) , which will set the $StartDate to today’s date, unless you’ve already set it to something different–or until you manually change it to something else];
letting you manually re-set any values that differ from that general pattern [like, $StartDate="August 1, 2020"]
providing protection from the program over-writing or undoing those custom values. If TB sees that you’ve already set a value, it won’t go in unbidden and change things around.
Realize that @mwra and @PaulWalters are well aware of this, just spelling it out in answer to original query.
Hi Mark, should have clarified – the second bullet point is how you would re-set the value, manually, either (a) before the |= operation ran, to prevent it from setting the date to “today,” or (b) after that operator had run, to change it to your preferred date.