Hi.
I have some custom fields in the Sales Invoice doctype with “Allow on Submit” checked. I need to validate that these fields are not empty, and if they are, I need to prevent the update to happen.
This is the Client Script I have tried but the events before_save or validate do not work
after_save does work when the form is submitted, but then I can’t prevent it from updating
frappe.ui.form.on('Sales Invoice', {
before_save: function(frm) {
if (frm.doc.docstatus === 1) {
if ((!frm.doc["orden_laboratorio_óptico"]) || (!frm.doc.laboratorio) || (!frm.doc["fecha_orden_laboratorio_óptico"])) {
frappe.validated = false;
frappe.msgprint(__("Some fields are missing."));
} else {
frm.doc.seguimiento_de_orden_de_laboratorio_creada = "1";
frm.refresh_field('seguimiento_de_orden_de_laboratorio_creada');
frappe.msgprint(__("Seguimiento Created succesfully."));
}
}
}
});
Any help is greatly appreciated