Open Random Draft by Tag

Posted by @galtenberg, Last update almost 6 years ago

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.


  • 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)
        if (
          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)]


  • 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.