Validate checkbox before save

i am validating the childtable rows that should not to be deleted before save and also after save with an if condition i.e a checkbox which is outside the childtable…if the checkbox is unchecked i need the childtable rows not allow to delete and also not allow to add a new row.

frappe.ui.form.on('Doctype', {
	childTableName_before_remove: function(frm, cdt, cdn) {
	    let data = locals[cdt][cdn]

        if(data.checkbox_name == 0){
            frappe.throw('Error Message', 'Error Title');

P.S. I have not tested the code.

Read List of Triggers .

Thanks for the reply,
i tried this but function is not called…

Make that field readonly.

checkbox: function(frm){
    cur_frm.set_df_property('child_table_field_name', readonly, cur_frm.doc.checkbox ? 0 : 1)

I have another condition also if the checkbox is checked then i have to delete and add a new rows in childtable…

1 Like

I made this code to make it writable when checked. Please try it out.

Replace checkbox and child_table_field_name by the appropriate field name in your parent doctype.

Please, share the code so we can help you.

In my case, if the checkbox(which is in child doctype) is checked then it should show that child doctype data/entries.
Any help for above condition?

Check if the checkbox is enabled in if condition then show the child doctype data fields using
if (frm.doc.checkbox_name == 1){
cur_frm.fields_dict[“table_field_name”].grid.toggle_display(“fields”, true);
cur_frm.fields_dict[“table_field_name”].grid.toggle_display(“fields”, false);

Thank you for replying.