Drafts Action Directory

Open Random Draft by Tag

Posted by @galtenberg, Last updated: 2018-07-03 22:22:00 UTC

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


  • After Success Nothing
    Notification Error
    Log Level Error


Actions available in the Action Directory are uploaded by community members. Use appropriate caution reviewing downloaded actions before use.