I want to stop the validation before cancellation because I assigned some logics to save in the fields and then after all I assign to cancel the document
use frappe.throw(msg);
to restrict submitting / saving form
1 Like
@Pejay Use this code
frappe.ui.form.on("Doctype Name", {
before_workflow_action: async(frm) => {
if (!frm.doc.status=="Submitted" && !frm.doc.custom_reason_of_cancel) {
let promise = new Promise((resolve, reject) => {
frappe.validated=false
// frappe.throw("Message to be shown")
})
frappe.dom.unfreeze();
await promise.catch(() => {
throw '';
});
}
}
});