Link Search Menu Expand Document
Table of contents
  1. Flow - drnew
    1. Description
    2. Variables
      1. Used
      2. Created
    3. Termination
    4. Flow
    5. Scripting
      1. Sample Code (AppleScript)
      2. URL
    6. Notes

Flow - drnew

Description

Creates a new draft in Drafts using AppleScript, and so not bringing the Drafts application to the foreground. The flow supports setting the flagged status of the new draft, as well as adding tags, and prefixing all lines with additional text. This can be useful for setting up Markdown lists (numbered or bulleted) for example.

The flow also supports running an action on the new draft, but this will force Drafts to come to the foreground and load the new draft in order to run the action.

Variables

Used

The following variables can be passed in and will be processed by the flow.

Variable Description
query * The base content to populate the new draft with.
action The name of an action to execute on the new draft once it has been created.
flagged Set as true or false to indicate if the new draft should be flagged or not.
prefix The text to prepend to each content line.
tags A comma separated list of tags to add to the new draft.

* These are mandatory for triggering this flow.

Created

The following variables are set-up by the flow.

Variable Description
content The (modified) content to populate the new draft with.
OpenDraft Always set to false, and determines the route through the flow.
NotificationTitle The title to be shown in any completion notification.
NotificationMessage The message to be shown in any completion notification.

Termination

Flow

drnew

Scripting

Sample Code (AppleScript)

tell application id "com.runningwithcrayons.Alfred" to run trigger "drnew" in workflow "com.thoughtasylum.doctordrafts" with argument "Lorem ipsum dolor sit amet"

URL

alfred://runtrigger/com.thoughtasylum.doctordrafts/drnew/?argument=Lorem%20ipsum%20dolor%20sit%20amet

Notes

  • Supports new lines from Alfred input as “\n”.
  • Supports tab characters from Alfred input as “\t”.
  • Accessing environment variables from an AppleScript run from within Alfred encounters UTF encoding issues. For this reason the AppleScript utilises embedded shell script to get the content and tags environment variables - i.e. in case they contain accented characters, etc.