TIP: Use temporary workspaces to filter the draft list

Workspaces are a great tool to define a filtered view of the draft list, but sometime you have searches/filters you only want to apply occasionally, or which are based on inputs that change - like input from a prompt in an action.

This Load Temporary Workspace action is a demonstration of something enabled by the recent addition of Workspace scripting.

It is now possible to create a workspace in script, define its various tag filters, query string, sort options, etc., and apply it to the draft list without ever saving that Workspace - so it will not be added to your Workspaces list.

Download the example action. Including the script below as well:

// BEGIN config variables
// setup tags or searches you wish to load...
let name = "Blue Things";
let tagFilter = "blue, !green"
let queryString = "";
// END config variables

// create workspace
// for other options, see:
// https://reference.getdrafts.com/objects/Workspace.html
let ws = Workspace.create();
ws.name = name;
ws.tagFilter = tagFilter;
ws.queryString = queryString;
ws.setInboxSort("modified", true);

// unless you call `ws.update()`, this ws is temporary
// load this workspace, and display draft list

app.applyWorkspace(ws);
app.showDraftList();
2 Likes

See, I told you you needed to beef up Workspace. :slight_smile:

Seriously, this is a nice example of a query.

I’ll have to read up more on the new enhancements to Workspace.

The documentation on that page needs a little finishing:

  • name [string]
    The name of the workspace.
  • queryString [string]
    The name of the workspace.
  • tagFilter [string]
    The name of the workspace.
  • tagFilterRequireAll [boolean]
    The name of the workspace.
1 Like

Just for info - same in the beta documentation site too.

Fixed the docs, thanks.

2 Likes

Just wanted to say this is awesome. I’ve created a temporary workspace for each key client I have, which allows me to quickly bring them up without having to clutter my primary workspace space with that long list.

2 Likes