Workflow Status Change Not Triggering in Server Script

Hi ERPNext Community,

I’m new to ERPNext and loving it, but I’m stuck on an issue.

I have a workflow where the status changes to “Zugewiesen” (Fieldname: workflow_status") on the action “Anfrage einem Mitglied zuweisen”. I want to trigger a server script when this happens.

Here’s my script with event before submit:

if doc.workflow_status == "Zugewiesen": 
 frappe.msgprint("Workflow_status changed to Zugewiesen")

This doesnt work.

With doc.docstatus in another script (also with before submit ) it works:

if doc.docstatus == 1: 
 frappe.msgprint("Workflow_status changed to Zugewiesen")

Any ideas why doc.workflow_status isn’t working? I can’t use docstatus because in my workflow, several statuses (including “Zugewiesen” ) all have docstatus == 0 . Its a multi step process…

This is probably a super noob question, but I’d really appreciate any help!

Thanks in advance :)!

Best, Jan from :de:

Please use doc.workflow_state instead of doc.workflow_status

Hello Jeel,

thanks for your answer!

I changed it, but doesnt work…

the field Name is workflow_status in workflow settings.

With JS i already found a way to do this. I would like to find in general a server-script solution to trigger a server-script when a workflow status changes.

bc this doesent work ://

@jan_wueste try this frappe/frappe/model/document.py at da7190a2ea9179c51d61384312fbf4d5abdf1c7b · frappe/frappe · GitHub 1

Hi Jeel,

thanks for your help!

Setting the Doctype-Event to: before_validate (“Vor der Validierung” :de:), got the job done!

I can now trigger scripts if workflow states change, thanks:)