Strange rule behaviour, seems to depend on order of attributes

Good evening, all.

I’ve been tinkering with a Rule for Bookends import. I’m gathering all my references in a References container, and I’d like, out of long-worn habit, a Harvard-style citation on the generated note. I also want a blank $Text field — I don’t need to duplicate the reference there, I might want to add some of my own text, so I prefer it empty. Here’s what I have so far:

$Text="";
$Name=$BookTitle+" ("+$PublicationYear+") "+$Authors

And that works OK (image below)…

Screenshot 2020-08-03 at 21.34.55

However, it’s not the citation style I want! I’d like Author(s) (Year) Title. Why haven’t I just done that? Well, because putting $Authors first seems to introduce a series of semi-colons and unwanted brackets. If I use the following:

$Name=$Authors+" ("+$PublicationYear+") "+$BookTitle

… I get a semi-colon after the authors, a pair of brackets after that, another semi-colon, a closing bracket, a semi-colon, and the book title! Again, image below:

Screenshot 2020-08-03 at 21.33.31

Any help appreciated! (And, as an aside, is there any way to extract only the year from $PublicationDate?)

Thank you.

$Authors is a Set. So, imported without formatting, the semi-colon you see is the list-delimiter character. You’ll have a bit more processing to do as for the format mention you want the last name and and an ‘and’ 9or ampersand) depending on the number of authors: one/two/three/four or more.

This seems to work:

var authorNames;
if($Authors){
   if($Authors.count==1){
      authorNames = $Authors.split(", ").at(0);
   };
   if($Authors.count==2){
      authorNames = $Authors.at(0).split(", ").at(0) + " and ";
      authorNames = authorNames + $Authors.at(1).split(", ").at(0);
   };
   if($Authors.count==3){
      authorNames = $Authors.at(0).split(", ").at(0) + ", ";
      authorNames = authorNames + $Authors.at(1).split(", ").at(0) + " and ";
      authorNames = authorNames + $Authors.at(2).split(", ").at(0);
   };
   if($Authors.count>=4){
      authorNames = $Authors.at(0).split(", ").at(0) + " et al.";
   };
};
$Text = ;
$Name = authorNames + " (" + $PublicationYear.split("-").at(0) + ") " + $BookTitle;

You might want to tweak the last line if you don’t different punctuation of the overall string.

That said, if you’re dragging the reference from Bookends, the process put a formatted string into $Text. So why not just use Harvard for the drag - or an edited form e.g. using Bookends → Biblio menu → Formats Manager…, if you only wan’t some fields to be carried across.

Ah, I knew it! About 10 minutes ago, I thought, “I bet it’s something with that $Authors attribute…”! Thank you, Mark, for taking the time to respond so fully. I’m toying with the Bookends demo right now, I’ll take a look as you suggest.

1 Like