Quote of the Day ... Eventually

I created a draft called Quote Library which has several one line quotes in it. I then created a two step action to select one quote at random and add it into daily journal via a template.

Following is my first script which selects the random quote.

var quoteDraft=Draft.find(“94623B9F-56AA-426D-9B54-4942CEDB3C1B”)
var quote=quoteDraft.lines
var l=quote.length - 1
var i=Math.floor(Math.random() * l) +1

My second step is just to include the existing action New Draft with Template. The template I select has the following in it.



My assumption is the first step would have defined the new template tag of [[dailyquote]] but what shows up is the literal [[dailyquote]] rather then the value assigned.

I’m sure it’s a noob error but any direction would be useful.


When you start the action you are using a draft instance called “draft” and that is what you use setTemplatTag() on.

Next, you create a new draft, let’s call it “draftNew”.

“draftNew” has access to the date as that’s a standard template tag and so populates it when requested to.

When requested to populate “dailyquote” however that is a custom template tag that has never been defined for “draftNew”, only for “draft”. Hence the result you see.

See below thread addressing essentially the same thing:

Thanks all,

What you are saying makes perfect sense. I was hoping to be able to use the existing New Draft with Template more as a puzzle fitting different components ahead of it but I see that won’t be possible. Since it will require a change to New Draft with Template to make it custom, I am probably better off just making a single script that does it all.

I think there probably is a way for me to set New Draft with Template to check for the presence of a “Custom Tag” variable and use it if present, but I’ll save that for another day.

So I went ahead and added the following to “New Draft with Template” action so I could easily include it passing different custom tags to it:

if (typeof custom !== “undefined”) {
d.setTemplateTag(“custom”, custom);
My preceeding action sets the var custom and if I don’t have a preceeding action i avoid the “undefined” error with the typeof check. Seems to work perfectly.