Action
Open Random Draft by Tag
Opens a prompt with recent tags to choose from.
Can set preferred tag(s) directly in the script, or in a script step before this (even if you Include this action), if you wish to skip the prompt.
Steps
-
script
// Set your own tag, here or in a script step before you include this action, if you'd like to bypass the prompt // let tag = 'goals' if (typeof tag === 'undefined') { tag = [""] } else if (typeof tag === 'string') { tag = [tag] } function randomDraft(tag) { if (!tag[0]) { const p = Prompt.create() p.title = "Choose tag to open random draft" p.message = "Leave unselected to pick any random draft" p.addSelect("tag", "", Draft.recentTags(), [], false) p.addButton("Choose") if (p.show()) tag = p.fieldValues["tag"] } let matchingDrafts = Draft.query("", "all", tag).filter(d => d.uuid != draft.uuid) if (matchingDrafts.length == 0) return const randomDraft = matchingDrafts[Math.floor(Math.random() * matchingDrafts.length)] app.openURL(`drafts5://x-callback-url/open?uuid=${randomDraft.uuid}`) } randomDraft(tag)
Options
-
After Success Nothing Notification Error Log Level Error
Items available in the Drafts Directory are uploaded by community members. Use appropriate caution reviewing downloaded items before use.