Action
Monthly Journal
Add text of current draft to monthly journal draft, creating the new draft if needed.
This action is an example of how to journal to other drafts within drafts. By default, it add the text of the current draft to a draft with the tag “journal”, and a title like “2019-11: Monthly Journal”. If that draft does not exist, it will be created.
The action is also configured to archive the current draft after running.
In combination with this, it is recommend you setup a journal workspace to easily filter your history of journal entries.
The action contains two script steps. The first contains configuration variables which can be altered to format the entry text, alter the naming conventions - or even make the system work for daily or weekly journal based on different template tags.
Steps
-
script
// Configuration Options /* Template to use as title for journal notes. Uses Drafts template tags to for current date, altering date format can control whether journals are daily, monthly, etc. The default `%Y-%m` will create monthly journals with titles like `# 2019-11-01 - Daily Journal` */ let titleTemplate = "# [[date|%Y-%m]]: Monthly Journal"; /* Tag to use to identify journal entries. Journals will be assigned this tag. Only drafts with this tag will be queried to locate existing journals. */ let journalTag = "journal"; /* Content template controls how the current draft will be appended to the journal The default includes a time stamp for the entry followed by the content of the current draft. Include any whitespace you with to have before next entry. */ let contentTemplate = `#### [[time|%d %B %Y %I:%M %p]] [[draft]] ` /* Optionally archive journals. If true, the journal drafts will be assigned to the archive instead of the inbox to avoid cluttering the inbox. */ let archiveJournals = false;
-
script
// setup values let title = draft.processTemplate(titleTemplate); // query for existing journals to see if one already exists matching the tag let drafts = Draft.query("", "all", [journalTag], [], "created", true, false); let d; let found = false // loop over found draft to find an existing journal entry for (let foundDraft of drafts) { if (found) { break } if (foundDraft.content.startsWith(title)) { d = foundDraft; found = true } } // if no draft was found, create one if (!found) { // no matching draft, create a new one... d = Draft.create(); d.content = title + "\n\n"; d.addTag(journalTag); } if (archiveJournals) { d.isArchived = true; } // append new content to journal draft let content = draft.processTemplate(contentTemplate); d.content = d.content + content; d.update();
Options
-
After Success Nothing Notification Info Log Level Info