Drafts Script Reference
    Preparing search index...

    Class Workspace

    Represents a Workspace. Can be used to inquire and load workspaces and apply them using methods on the App object.

    Note that is can also be useful in script to create and load temporary workspaces to apply filters or query drafts. If you create a new Workspace object and never call update() that workspace will not be saved after the end of an action's execution.

    Find and Load Workspace

    // find workspace and load it in drafts list
    let workspace = Workspace.find("Projects");
    app.applyWorkspace(workspace);
    Index

    Display

    archiveIncludesFlagged: boolean

    Should flagged drafts be included in archive.

    inboxIncludesFlagged: boolean

    Should flagged drafts be included in inbox.

    loadActionBarGroup?: ActionGroup

    Action group to load in Action Bar when applying the workspace.

    loadActionListGroup?: ActionGroup

    Action group to load in action list when applying the workspace.

    loadFolder?: draftFolderTab

    Folder tab to select when applying the workspace.

    preferredDarkTheme?: Theme

    Preferred dark theme to load when applying the workspace.

    preferredLightTheme?: Theme

    Preferred light theme to load when applying the workspace.

    showDate: boolean

    Show date information in list.

    showLastAction: boolean

    Show last logged action for draft in list.

    showPreview: boolean

    Show preview of draft body in list.

    showSearchPreview: boolean

    When a queryString value is set for the workspace, replace the preview text content with a summary of matches in the text.

    showTags: boolean

    Show draft tags in list.

    Filter

    endDate: QueryDate

    A QueryDate specifying a date which all drafts in the workspace must be less than or equal to.

    flaggedStatus: flagStatus

    Filter by flagged status of drafts.

    queryString: string

    Search string to filter results.

    startDate: QueryDate

    A QueryDate specifying a date which all drafts in the workspace must be greater than or equal to.

    tagFilter: string

    Comma-delimited list tag string like "blue, !green" using "!" to omit a tag.

    tagFilterRequireAll: boolean

    If true, all (AND) tags in the tag filter must match, if false match any of the tags (OR)

    Identification

    installURL: string

    URL which can be used to install this Workspace in another installation of Drafts. Useful for sharing and backups.

    name: string

    The name of the workspace.

    Other

    • Query for a list of drafts contained in the workspace.

      Parameters

      • filter: "inbox" | "flagged" | "archive" | "trash" | "all"

      Returns Draft[]

    • Save changes made to the workspace to the database. This must be called to save changes.

      Returns void

    • create a new workspace object. This is an in-memory object only, unless update() is called to save the it. The initial state of the workspace properties is based on the configuration of the user's default workspace.

      Returns Workspace

    • Search for workspace matching the name passed and return it if found. Returns undefined if not found.

      Parameters

      • name: string

      Returns Workspace

    Sort

    • Set sort order for "all" drafts folder.

      Parameters

      • sortBy: sortBy
      • sortDescending: boolean
      • sortFlaggedToTop: boolean

      Returns void

    • Set sort order for archive.

      Parameters

      • sortBy: sortBy
      • sortDescending: boolean
      • sortFlaggedToTop: boolean

      Returns void

    • Set sort order for flagged.

      Parameters

      • sortBy: sortBy
      • sortDescending: boolean

      Returns void

    • Set sort order for inbox.

      Parameters

      • sortBy: sortBy
      • sortDescending: boolean
      • sortFlaggedToTop: boolean

      Returns void