Quick Entry Doctype events are not working

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')
        }
       
    }
});

Can you give some idea’s about the above query

Hi @Sharan_M,

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;
        }
    }
});

Thank You!

Which events are supported in the Quick Form?

it’s not working in Quick Form

Sorry @TurkerTunali and @Sharan_M,

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.

Thank You!

1 Like

for that we can use python event for validate @NCP
Thank you !

Hi @Sharan_M,

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.

Thank You!

I admire your overall experience and know-how of Frappe Framework.

1 Like