Load a folder/tab in a script

Hello,

Ideally, I would like a script that would load the ‘Default’ workspace, and select the ‘inbox’ or the ‘flagged’ tab (based on a conditional statement).

I can’t work out how to load the ‘Default’ workspace, so I have created a ‘Drafts’ workspace, which I can apply like this:

let workspace = Workspace.find(“Drafts”);
app.applyWorkspace(workspace);

However, I don’t know how to load the ‘Inbox’ tab, or the ‘Flagged’ tab. Does anyone know? I want to load different tabs depending on the action.

Thanks,

Andy

Couple of notes:

If you create a new Workspace object, it is configured like your default workspace. So let workspace = new Workspace() will get you the default workspace.

Workspaces can select a folder when applied. So, if you want to programmatically select which to apply, you can set the loadFolder property of the workspace object before applying it.

So, something like:

let workspace = new Workspace();
if (wantsFlagged) { // whatever your logic for choosing folder is here...
    workspace.loadFolder = "flagged";
}
else {
    workspace.loadFolder = "inbox";
}
app.applyWorkspace(workspace);
1 Like