Hi folks,
This is purely related to the validation of doc fields at client side. Requirement: To validate additional_discount_percentage in “Sales Invoice” doctype such that user does not put negative discount percentage.
erpnext version:11
code snippet used:
frappe.ui.form.on("Sales Invoice", "validate", function(frm) {
if (frm.doc.additional_discount_percentage < 0 {
frappe.msgprint(__("You can not select negative discount"));
frappe.validated = false;
}
});
Screenshot 1: Created a custom script to validate docfield.
@kumar404
you missed ‘)’ after condition
correct form
if (frm.doc.additional_discount_percentage < 0) {
frappe.msgprint(__(“You can not select negative discount”));
frappe.validated = false;
}