Does anyone know the reason why frappe.validated = false doesn't stop the validation

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
image

use frappe.throw(msg); to restrict submitting / saving form

1 Like

Thanks bro @ejaaz . But the thing is the prompt doesn’t show when using frappe throw.

@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 '';
		});
        }
    }
});

Check your code conditions
https://imgur.com/EXxgv8z