Action
Assign Draft to Workspace
This is a slightly reworked version of agiletortoise’s “New Draft in Workspace” action (https://actions.getdrafts.com/a/1Tx)
It allows you to choose a workspace and it assigns the tags to the current draft. Note that all existing tags are removed first.
It can be used to move a draft to a new workspace, but was mostly created because I keep forgetting to use Greg’s action to create drafts with the right tags
Steps
-
script
// Assign current draft to selected workspace let f = () => { let workspaces = Workspace.getAll(); if (workspaces.length == 0) { alert("No workspaces defined."); return false; } let p = Prompt.create(); p.title = "Assign Draft to Workspace"; p.message = "Select workspace. Current draft will be assigned tags to match the workspace."; let ix = 0; for (let ws of workspaces) { if (ws.tagFilter.length > 0 && ws.tagFilter.trim() != "untagged") { p.addButton(ws.name, ix); } ix++; } if (!p.show()) { return false; } let selectedIndex = p.buttonPressed; let ws = workspaces[selectedIndex]; for (var tag of draft.tags) { draft.removeTag(tag); } let tags = ws.tagFilter.split(",").filter(tag => tag.trim().length > 0 && tag.trim()[0] != "!" && tag.trim() != "untagged") for (var tag of tags) { draft.addTag(tag); } draft.update(); return true; } if (!f()) { context.cancel(); }
Options
-
After Success Default Notification Error Log Level Error
Items available in the Drafts Directory are uploaded by community members. Use appropriate caution reviewing downloaded items before use.