I am facing an issue while using the Quick Entry form in ERPNext for creating new customers. I want to make certain fields mandatory, such as phone number and email address, but despite trying different client-side validation scripts, I am unable to achieve this. I have tried the following scripts:
frappe.ui.form.on("Customer", "validate", function(frm) {
var fields_to_check = ["email_id", "mobile_no", "customer_primary_address", "customer_primary_address_city", "customer_primary_address_state", "customer_primary_address_country"];
for (var i = 0; i < fields_to_check.length; i++) {
if (!frm.doc[fields_to_check[i]]) {
frappe.msgprint(__("Please enter a value for {0}", [fields_to_check[i]]));
validated = false;
}
}
});
frappe.ui.form.on("Quick Entry Customer", "validate", function(frm) {
if (!frm.doc.gstin) {
frappe.msgprint(__("Please enter a value for Phone Number"));
validated = false;
}
});
frappe.ui.form.on("Customer Quick Entry", "validate", function(frm) {
if (!frm.doc.gstin) {
frappe.msgprint(__("Please enter a value for Phone Number"));
validated = false;
}
});
None of these scripts seem to work in the Quick Entry form, and I am still able to create customers without providing mandatory fields. I have also checked that making the fields mandatory in the Customize Form option does not help either.
Is there a way to make these fields mandatory in the Quick Entry form, either through client or server-side scripts? Any help would be appreciated.
Thanks in advance.