In addition to being able to lookup an action using the find method, a single global action object is created and available in scripts to inquire about the current action and control flow.

Example

Queuing an action to run

// find action by name
let otherAction = Action.find("Copy");

// queue to action to run after the current action, on the same draft
app.queueAction(otherAction, draft);

Branching based on current action

// use global `action` to branch logic in a script reused in multiple actions
if (action.name == "Copy") {
// do something
}
else {
// do something else
}

Hierarchy

  • Action

Identification

Other

Query

Identification

installURL: string

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

isSeparator: boolean

If true, the action is a separator.

name: string

The display name of the action as displayed in the action list.

uuid: string

The unique identifier of the action group.

Other

Query

  • Search for action matching the name passed and return it if found. Useful to lookup and action and queue it to be run using the App.queueAction function of the App object. This method will return only the first found action with the given name, be sure to avoid duplicate names in your action list.

    Parameters

    • name: string

      Name of a valid, installed action.

    Returns Action

Generated using TypeDoc