Random Draft Action

Description

Opens a random draft in the editor.

Directory description

Opens a random draft in the editor. Offered by FlohGro in response to this forum thread.

// query all drafts with any tag (filter out the current open draft) 
const allDrafts = Draft.query(“”, “all”,[]).filter(d => d.uuid != draft.uuid)
// get a random draft from the allDrafts array by creating a random number between 0 and the count of drafts in allDrafts
const randomDraft = allDrafts[Math.floor(Math.random() * allDrafts.length)]
// load the random draft into the editor
 editor.load(randomDraft)