Tinderbox Forum

Disappearing field


(Lew Friedland) #1

I am trying to create a new file, imported prototypes that were working well for me.
Now in this this new file, when I enter a new title into the “BookTitle” field, I see it, but once I click out of the note it disappears.
I’ve messed with these a bit and just don’t see any errors in the OnAdd code, or differences. Appreciate any help. Thanks.Master2019.tbx (99.8 KB)


(Mark Anderson) #2

I first tried the note “Complexity Theory and the Social Sciences” and sure enough, on change of focus, the $BookTitle changed. The immediate giveaway was that whilst the attribute was empty, the KA item had the title bolded - so not default value but set to an empty string. Sure enough, the note uses the prototype ‘BookReference’ whose rule includes this code:

$BookTitle=$BookTitle(parent); 

Well, “Complexity Theory and the Social Sciences” is a root-level note so the parent is the doc root, i.e. the default value of $BookTitle. Checking via the Document Inspector, the doc default for the attribute is [no value].

So, garbage in, garbage out … :grin: Anyway, I’m not poking fun - what were you thinking would happen - or wanted to happen for a note using this prototype?

FWIW, I try to avoid using the same $Color for attributes unless some other (Outline-visible) characteristic such as $Badge differs. If notes using different prototypes look the same it offers endless scope for unexpected results.


(Lew Friedland) #3

Mark, thank you as always.
I guess I can’t always recognize garbage in code :wink:
But I had a feeling that might be the problem.
It’s actually something I had adopted earlier on your advice but that was for inheritance so that once I made a note for, e.g. Jones, Complexity, all subsequent notes would inherit those fields. I guess I misplaced that same code at the root level.
Always learning.


(Mark Anderson) #4

No problem, easy mistake to make. More importantly, I’m glad you’ve now found the glitch.


(Lew Friedland) #5

Trying to go to the doc inspector and see what you mean about KA set to empty string. I have it open, as attached. But I realize as I’m trying to repair the file that I don’t understand what _should_be in the default field. It’s a prototype, used for many books, so shouldn’t the default field be empty? Pretty sure I had not set it to any other setting before.


(Mark Anderson) #6

Strings, by default, generally have no value - i.e. the ‘Default’ box would be empty. So, how you’ve illustrated it looks good.

However, if you’ve used action code to set a per-note $BookTitle, the above won’t (can’t!) fix that - it simply stops all note’s inheriting a global book title value which is what I expect you did first off.

If confused, see my walkthrough on inheritance, here.


(Lew Friedland) #7

Have read through inheritance section of TBref carefully. I do understand the general logic, but can’t solve the title problem. So let me see if I can articulate what should happen.

The BookNote Prototype is at the root level. This should not have any OnAdd code related to fields (which I assume is what is triggering the default empty field for BookTitle, although I’m still confused about why it is _only_that field and not Authors, etc.). It _can_have OnAdd code related to a second prototype, BookChapter, which simply says, on adding a note to BookNote, make this note the Prototype BookChapter. _This_prototype, the book chapter, can have full inheritance from the BookNote (authors, title, etc.) but not, of course the BookNote prototype which would reset it to root again.

Sorry to keep returning to this, but trying to fix to troubleshoot this recurring problem permanently.


(Lew Friedland) #8

For what’s it’s worth, I’m including a stripped down version that I tried to rebuilt from scratch with only one BookNote prototype and one reference.Test.tbx (81.5 KB)
As a note, there is code under Rule that is for importing references from Zotero that you and others helped me develop. Not sure if that is a source of the problem. Thanks.


(Mark Anderson) #9

The error in Test.tbx is that in both cases, the prototype rule sets $BookTitle to its existing value. On first run of the rule, this sets the local value of the prototype’s $BookTitle to the doc default for $BookTitle, which is no value. So now, both prototype have a fixed local value of "" for $BookTitle.

So far, the app is working correctly as per your code, except I don’t think that’s what you meant to do. However, it would be easier to understand the problem if you stated, discreetly form the general discussion here—or better, within the test doc itself—what you expect to happen and why/how?

From experience, the best course of action at this point si to delete all code, etc. that does not relate to the attribute in question. Then, make that operate as expected. Only then add back other code, in case it is the latter that is (unseen) breaking the actual process you want to achieve.

I’ve uploaded a file for this, please fill out the ‘Instructions’ note for us and re-post:

Test-3.tbx (80.2 KB)


(Lew Friedland) #10

I’m trying to troubleshoot (in this new file) a procedure that you helped me define a bit over a year ago (and it worked well). That thread is here: Simplest form of inheritance for citation

(I’m using Zotero, and am starting to think I should switch to BookEnds, but nonetheless…)

What I want to happen is:

  1. create two basic prototypes, one for books and the other for journal articles with the fields: authors, title, publication date, etc. (as in this file).
  2. Drag and drop an entry from Zotero and have info transfer (this does work in current file versions; the code in Rules that you helped me write has worked consistently; see previous thread).
  3. Set a note’s prototype (as either book or article).
  4. Create a second set of prototypes (book note, article note) that will inherit all of the information from the filled in book or article note), so I can take continuous notes without having to reproduce that information per note. Presumably, through OnAdd code.
    I assume the function of this OnAdd code would be: transfer information from parent note (e.g. Book) to child (e.g. Chapter One).
    So far this is happening with the exception of the BookTitle. I think I may be figuring out the glitch. BookTitle is a fixed attribute, drawn from BookEnds, so it has the default empty field. I think before, I was not using the fixed attribute BookTitle, but a user attribute that I had created. Is this where the new inheritance problem may be coming in?

Thank you.


(Lew Friedland) #11

Mark, I’ve just reverted to a previous version based on our original thread that is working. I was trying to improve it and turn it into a master template and obviously have just introduced errors. Just for your reference, I’m including the file that _does_work as intended, but I don’t want to take more of your time. I’ll try to to figure the logic from this one. For whatever reason, the title issue is not a problem here. Thanks as always for your help.Master2019A.tbx (238.3 KB)
<a class=“attachment”


(Mark Anderson) #12

Not exactly. $BookTitle is blank by default in the TBX document. When you import the Bookends note it will (if there is source data) set $BookTitle using the imported RIS data.

You probably want to ensure your prototypes with fules have their rules disabled (so the rule never runs on the prototype itself) and if necessary reset inheritance on any prototype attributes mistakenly set via the rule before is was turned off. $RuleDisabled is not inherited so disabling it in the prototype does not affect the notes using the prototype, which run their rules as normal.

Anyway, why not put the code into the ‘Test-3’ file above so we can look at the issues without the noise of other tasks causing confusion.