Skip to main content

Workflow Transition Tasks

Workflow Transition Tasks allow you to execute predefined actions automatically whenever a document moves from one workflow state to another. Each Workflow Transition can have one or more transition tasks attached, enabling custom automation during approval processes.

Note: Available from Version 16.

Supported Task Types

Each Workflow Transition Task can execute one of the following action types:

  • App-Defined Actions – Actions provided by Frappe applications through hooks.py.
  • Server Scripts – Custom scripts created using the Workflow Task script type.
  • Webhooks – HTTP requests triggered during workflow transitions.

Execution Modes

Synchronous Tasks

Synchronous execution is the default behavior. Tasks are executed one after another while the workflow transition is in progress. If any task fails, the workflow transition is rolled back and the document remains in its previous state.

Asynchronous Tasks

When the Asynchronous option is enabled, the workflow transition completes immediately and each task runs separately as a background job. Failures in asynchronous tasks do not affect the completed workflow transition.

App-Defined Actions

App-defined actions are provided by Frappe applications through the workflow_methods hook in hooks.py. Each method accepts the current document (doc) as its parameter and performs the required operation.

Once an application registers these methods, they become available in the Tasks dropdown while configuring Workflow Transition Tasks.

Note: End users cannot create App-Defined Actions. They are available only when provided by installed applications. For custom automation, use Server Scripts.

Server Scripts

Server Scripts can be attached to Workflow Transition Tasks by creating a script with the Workflow Task script type. The script receives the current document as the doc parameter and executes whenever the transition occurs.

After creating the script, select it while configuring the Workflow Transition Task.

Webhooks

Workflow Transition Tasks can also trigger Webhooks to notify external systems whenever a workflow transition occurs.

To use a Webhook:

  • Create a Webhook.
  • Set the Doc Event to workflow_transition.
  • Select the Webhook while configuring the Workflow Transition Task.

Related Topics

  • Workflow State
  • Workflow Actions
  • Workflows
Rating: 0 / 5 (0 votes)