I have 5 check box what i need is the user must click the one of the check box it’s working on the full edit form but in quick entry it’s not validate the check box
frappe.ui.form.on('Designation', {
before_save: function(frm) {
// Check if at least one checkbox is selected
var designation_config_list = [frm.doc.is_technical, frm.doc.is_hr, frm.doc.is_bd_team, frm.doc.is__non__technical, frm.doc.is_accounts]
var count_of_one = designation_config_list.count(1)
if (count_of_one == 0){
frappe.throw('Please Select Anyone Of The Designation Classification')
} else if (count_of_one > 1){
frappe.throw('Please Select Only One Designation Classification')
}
}
});
Please apply it.
You can use the validate event instead of the before_save event. Using the validate event, which is triggered before saving the form.
frappe.ui.form.on('Designation', {
validate: function(frm) {
// Check if at least one checkbox is selected
var designation_config_list = [
frm.doc.is_technical,
frm.doc.is_hr,
frm.doc.is_bd_team,
frm.doc.is__non__technical,
frm.doc.is_accounts
];
var count_of_one = designation_config_list.filter(function(checkbox) {
return checkbox == 1;
}).length;
if (count_of_one === 0) {
frappe.msgprint('Please select at least one designation classification');
validated = false;
} else if (count_of_one > 1) {
frappe.msgprint('Please select only one designation classification');
validated = false;
}
}
});
There is no built-in event or method to directly handle custom validation in the Quick Entry form. The Quick Entry form is designed for fast data entry and doesn’t provide the same level of customization as the full edit form.
Yes, you can also use Python events to perform custom validation on the server side. By benefitting the before_save event in a custom Python script, you can validate the data before it is saved to the database.