From https://frappeframework.com/docs/v13/user/en/api/form#, there seems to be no way to halt the script from Saving if I detected there is error in Form.
Any solution?
From https://frappeframework.com/docs/v13/user/en/api/form#, there seems to be no way to halt the script from Saving if I detected there is error in Form.
Any solution?
Yes, there’s
frappe.ui.form.on('Sales Invoice', 'validate', frm => {
if (frm.doc.customer === "The X Man's") {
validated = false;
frappe.throw(__("You can't make a sell to The X Man's!"))
}
})
@charleslcso I think that you can also return a promise reject…
frappe.ui.form.on('Sales Invoice', 'validate', frm => {
if (frm.doc.customer === "The X Man's") {
validated = false;
return Promise.Reject();
}
})
frappe.ui.form.on('Sales Invoice', 'before_save', frm => {
if (frm.doc.customer === "The X Man's") {
validated = false;
return Promise.Reject();
}
})