Custom script / workflow action handler

Hello,
I created a Doctype called “action” and a workflow for this Doctype. This workflow has two status: Pending and Closed. And one workflow action: “Check”.

On my Doctype “action”, I’m trying to make the field “new_customer” mandatory only if the field “action_type” is equal to “aty001” when the user change the workflow status of a record using the workflow action: “Check”.

I believe that I to use a custom field looking like:

cur_frm.cscript.custom_**xxx** = function(doc) {
    if (doc.action_type === "aty0001" && doc.new_customer.length === 0) {
    msgprint("Please add a new customer.");
    validated = false; 
    }
} 

But I don’t know what handler to use (xxx).

Thanks for your help :smile:

Hello everyone,
I found out how to do this: I used the before_submit event. For that I managed my workflow to make the “check” action transit in status linked to submitted Doc status.