Action
Find Drafts with Many Versions
Search your drafts history for drafts with more than a certain number of versions in their version history and generate a new draft with links to those drafts for review.
Mostly meant as an example, but useful to hunt down large drafts that might be taking up a lot of space, etc.
Steps
-
script
// generate summary of drafts with many versions let min = 100; let p = Prompt.create(); p.title = "Find Excessive Versions"; p.message = "Locate drafts with more than the requested number of versions in their version history and generate a new draft with links to the drafts found."; p.addTextField("ct", "Min. Versions", min.toString()); p.addButton("OK", "Scan Drafts", true); if (p.show()) { min = parseInt(p.fieldValues["ct"]); let found = []; let all = Draft.query("", "all"); for (let d of all) { if (d.versions.length > min) { found.push(d); } } if (found.length > 0) { let s = "Below is a list of links to drafts with more than " + min + " versions. Use link mode to enable links in this draft and navigate to the drafts.\n\n"; for (let d of found) { s = s + `- ${d.title}: ${d.permalink}\n`; } let newDraft = Draft.create(); newDraft.content = s; newDraft.update(); editor.load(newDraft); } else { alert("No drafts with more than " + min + " versions found."); } } else { context.cancel(); }
Options
-
After Success Default Notification Info Log Level Info
Items available in the Drafts Directory are uploaded by community members. Use appropriate caution reviewing downloaded items before use.