Open Workspace with each Draft open in its own tab

I have a workspace containing Drafts marked with a Red Flag. This is my daily work workspace so I would like to be able to open it and then as it opens, go on to open each Draft in the workspace in its own tab.

I do this manually but I would like it automated. I’ve had a look around but can’t come close to finding anything to do it. I’d appreciate any ideas or better, a solution.

Thanks

Ian

Try something along the lines of:

// get the workspace
let ws = Workspace.find("My Workspace")
// load the inbox drafts in the workspace
let drafts = ws.drafts("inbox")

// loop over the drafts and open them
for(let d of drafts) {
    app.currentWindow.openInNewTab(d)
}
1 Like

Thank you, I’ll have a look at something like that and let you know.

Ian

I had a problem with the “let Drafts …” line, but the following works even if it isn’t the most consistent or elegant code ever seen on here :slight_smile:

// get the workspace
let ws = Workspace.find("Live")
// load all drafts in the workspace
ws.loadFolder = "all";
app.applyWorkspace(ws)
let drafts = Draft.query("flag:red","all","",false);
// loop over the drafts and open them
for(let d of drafts) {
    app.currentWindow.openInNewTab(d)
}

Thanks for your help with this.

Ian