Tinderbox Forum

Disappearing Attribute in Agent Search Results

I have developed a fairly simple TB project to organize and process my research notes. There are containers with a Reference prototype that have all the information about the book or article - authors, date, title, etc. Under each Reference, I have multiple notes (with a Note prototype) from the article. Both the Reference and the Note prototypes have a $CitationKey attribute. The Notes are set up to populate the CitationKey from the parent reference by means of a rule in the Note prototype: $CitationKey=$CitationKey(parent).

Now for the problem. I have agents set up to search for text strings in the notes. The agents work fine, except that the CitationKey attributes disappear. When I create a new note, or edit a note, the CitationKey field for the note under the agent search results displays correctly. But if I click on another note and then come back to the new note under the agent results the CitationKey field is blank. The contents that were there have disappeared.

So my question is, how can I keep the contents of the CitationKey fields from disappearing in the lists of agent search results?

1 Like

Hi @oranghutan, thanks for the post.

I have reproduced your experience and TBX is doing exactly what you’re telling it to do, make the $CitationKey=$CitationKey(parent). See attached, For-oranghutan.tbx (144.0 KB)

I just simulated what is happening in the attached file. If I’m not mistaken what you are saying is that the alias notes have their $CitationKey disappearing (not the original notes), which makes sense. What is happening is that the aliases are running the rule and picking up the $CitationKey from the parent, in this case, the agent container that has an empty $CitationKey. When the rule runs on the root, which does not have a parent it deletes the $CitationKey (again, TBX is doing what you’re telling it to do).

Take a look a the attached file. I do something very similar to you, but rather than running a rule I use $AddOn, which adds the citation to the child note when the note is added to the container. See the difference between Davis, 2020 which is based on a prototype running the rule, and Kyle, 2019 which is based on the AddOn action.

I hope this helps.

1 Like

Thanks Michael!

That solves the problem. I am a newbie at TB and still trying to figure out the nuances of Rules vs. Actions. This adds to my understanding. I have been messing with this for two days; should have asked the question earlier. Again, I very much appreciate your help.

Kyle

2 Likes

Yay, community help FTW! To flesh the underlying point out a bit, beware of a Rule or Edict that has code like:

$SomeAttribute = $SomeAttribute(parent);

or

$SomeAttribute = $SomeOtherAttribute(parent);

…if you are going to use agents. An alias has no kids, so $OnAdd is OK. But for an alias within an agent the ‘parent’ is the agent and probably not what you intended when writing the original code.

So for a rule or edict (indeed, a stamp which might act on an alias), it might be safer to use:

$SomeAttribute = $SomeAttribute(parent(original));

or

$SomeAttribute = $SomeOtherAttribute(parent(original));

For an alias in an agent, this looks for the parent of the alias’ source (i.e. ‘original’) note. now, wherever the alias is placed - in an agent or elsewhere, calling the ‘parent’ value returns the same data.

1 Like

Totally get it. Me too. :wink:

BTW, her is another trick. You might consider modifying your OnAdd with this:

if($CitationKey==""){$CitationKey=$CitationKey(parent)};

The conditional statement will check if $CitationKey is empty. If it is it will add the citation, if it is not, i.e. you have a not that you’ve already given a citation, then it will not overwrite what you’ve already put in there.

This is nice, as it will let you move notes between folders without first on another OnAdd overwriting you $CitationKey.

Come back any time.

You can also use a ‘logical OR’ (see more):

$CitationKey|=$CitationKey(parent)

Which does the same as the if() statement above.

1 Like