Setting attributes when a Reference is imported from Bookends

When I ⌘ ⌥+drag a reference from Bookends to TB8.2.1, a note is created with Reference prototype. The problem is the $Text of the note is set to the contents of (what seems to be) $ReferenceRIS, that is:

TY  - JOUR
AU  - Ertelt, Denis
AU  - Small, Steven
etc.

What I would like to do is set $Text to the text of the abstract, but only when the note is initially created - I’ll want to make edits later.
I have the following code that should do what I want, and let me know if it doesn’t work for some reason:

if ($ReferenceRIS.contains("^AB  - ([^\r]+)\s*$")) { $Text = $1; } else { $Text = "nope"; }

I’m not sure where I should put the code.
I found an Edict for setting BibTexKey, but I believe Edicts run about every hour, so that won’t work. Rules run every few seconds.
This seems like an FAQ, but I’ve been searching and experimenting for quite a while. Thanks for any help!

When I Cmd+Opt drag a BE reference the note $Text is not RIS code, as you describe, but formatted text based on that data. However, the RIS data is in $ReferenceRIS.

I used your code example and the $Text became the reference’s abstract (i.e. the RIS ‘AB’ field data). So if it doesn’t work for you there must be a further aspect to the process you haven’t described.

Actually, a much easier method to test for the abstract set that as the $Text is to read the $Abstract attribute:

if($Abstract!=""){$Text=$Abstract;}else{$Text="No abstract available";}

You only want to do this once per (reference) note so a $Rule isn’t ideal. I’d use a stamp. This gets you around having to put a guard attribute in so you can tell if a reference note has had its $Text altered.

Note that rules and edicts can be run on demand by clicking the ‘Run now’ button on their Inspector pane. So, you can have the failsafe of the edict re-running every hour and still use it on demand. But as I say, you really only want to do this once so a stamp seems a better method toi use.

1 Like

Thanks Mark, I appreciate your taking the time to reply.

In the recent past, mine has created refs without RIS data in the note’s $Text, I’m not sure what has changed. I created a new TBX file, added the default Reference prototype, and a Cmd+Opt+Drag exhibited the same behavior (RIS in the note $Text). Maybe I’m solving the wrong problem with my code. Part of the reason is I don’t know how to determine if it’s Bookends or Tinderbox. Can I assume since my import into an empty TBX doc didn’t work, that it’s probably a Bookends formatting issue? Does TB just dump RIS into $Text if it doesn’t parse correctly?

I was under the impression that Tinderbox accepted whatever format you had chosen in Bookends – be it MLA, APA, Harvard, or a format that you had devised yourself. If you look at the bottom of the Bookends window, there is a row of icons that allow you to view the tags, the URL, format or the attachment of the item you have selected. I believe that if you change the format using the selections there, you change what is sent to Tinderbox. But I stand to be corrected – I can’t remember precisely.

Ah, this is an issue at the Bookends side of things. To initiate correctly loaded/formatted drag data, you must press Cmd+Opt before you start the drag. Why that should matter is probably down to some issue in a long forgotten version of the Mac’s OS. Either way, it’s a limitation arising in Bookends which can’t be fixed at the Tinderbox end.

Another effect of an incorrectly initiated drag is the References prototype isn’t applied in Tinderbox and the reference-related attributes such as $Abstract aren’t populated for you.

So, yes, you are perhaps solving the wrong problem, but for a hard to detect problem arising outside Tinderbox. Once you get the inbound drags working correctly, the abstract data will be waiting for you in $Abstract.

(But see my next answer too…)

Yes that is true. Assuming the Cmd+Opt trigger is set correctly when starting the drag in Bookends the contents of $Text will be in the currently-set Bookends export format. But, I think a correct drag also passes a fuller set of reference fiends (in RIS form).

Thus, even if the Bookends export format doesn’t include the abstract (such as send in the imported $Text). However, if you look at $Abstract you will find the data has imported.

I’ve learned a bit more about this process.
When working in the Formats Manager in Bookends, whichever format is selected becomes selected in the BE interface. So the nicely formatted Reference was being created when Ref with Abstract was selected, and the more raw RIS References were being created when I had just edited the RIS format.
So I don’t think I’ve every had a nicely formatted note (a citation followed by the abstract), while simultaneously having the meta-data attributes filled in from RIS info.

I’ve done this, and it works well. This seems to be the most parsimonious solution at the moment.

Thanks all for the help!

1 Like