Mandatory depends on issue on workflow_state

I noticed a strange thing with mandatory depends on. I created a custom doctype and a workflow for it. all works well but later I added mandatory depends on eval: [“Signature Pending”].includes(doc.workflow_state). its showing mandatory but when I click on next action its not validating the mandatory fields and directly moving to next state and in the next state those fields are not mandatory.

please help me on this.

Give me the condition you wrote in a mandatory_depends_on field

eval: [“Signature Pending”].includes(doc.workflow_state).

this working fine because I am seeing those fields as mandatory in that stage but not validating when i click on next action

I think mandatory check works only on form saving but not when its clicked on workflow action

Yes you are correct, create validations using some scripts for workflow

before_workflow_action: function (frm) {
if(frm.selected_workflow_action==“Pending Signature”){
let keys = [“signature”,“full_name”,“title”,“vdate”]
checkMandatoryFields(keys,frm) }

}

function checkMandatoryFields(keys,frm){
frappe.dom.unfreeze();
let missing_keys=“”
for (let key of keys) {
if (!frm.doc[key] || frm.doc[key] === null || frm.doc[key] === undefined) {
missing_keys+=<li>${key}</li>
}
}
if (missing_keys){
frm.scroll_to_field(“signature”)
frappe.throw({
title:“Missing mandatory fields”,
message:missing_keys
})
return false
}

}