Drafts provides a handy script method to select an existing draft, which prompts you with a draft browser and returns the draft selected. Using this method makes it easy to work with existing drafts.
A couple of quick, ready-to-use example actions which take advantage of this method:
- Append to Draft: Prompts to select a draft, and appends the content of the current draft to that draft - then archiving the draft. Useful when typing a quick note you later want added to a longer draft you had in-progress. Works much like capturing with the Drafts’ Share extension from another app.
- Insert Draft at Cursor: Prompts to select a draft, and inserts the content of the selected draft in the current draft at the cursor. Great for using other drafts a re-usable snippets.
In your own scripts, the method is
app.selectDraft(), and is used as follows:
let d = app.selectDraft();
After that line, the
d variable contains a
Draft object, and any of the content and other properties of the object can be used.