Workflow Transition Tasks
Note: To be added in version 16
Introduction
Each Workflow Transition Task can have tasks of the following types:
- App-Defined Actions (specified by each Frappe app through hooks.py)
- Server Scripts
- Webhooks
On top of this, each transition task can be either:
- Synchronous: This is the default mode of transition tasks. All of the transition tasks run one-by-one when the state transition is initiated. Even if one of them fails, the transition is reversed.
- Asynchronous: This mode can be enabled using the 'Asynchronous' checkbox. Each asynchronous transition task runs after the state transition is completed, meaning it has zero influence over state completion, and is run in a separate background job of its own.
App-Defined Actions
Each Frappe app defines them using the 'workflow_methods' hook.
Any dotted path method defined through the workflow_methods hook has to accept doc: Document as the parameter, which is the document on which the transition is being applied.
An example of an app-defined task is:
# hooks.py
workflow_methods = [{"name": "Create a customer", "method":
"myapp.shop.doctype.kirana.create_customer"}]
# myapp/shop/doctype/kirana.py
def create_customer(doc):
customer = frappe.new_doc("Customer")
customer.customer_name = "Customer " + doc.name
customer.customer_type = "Individual"
customer.save()
If you are an end user, you can not create app-defined actions on your own and will have to use server scripts as mentioned below.