How to delete only specific row from child table?

here i only want to delete row which has status initiated. But even the status with any get deleted when i click red delete button


 before_order_list_table_remove: function(frm, cdt, cdn) {
        let row = locals[cdt] && locals[cdt][cdn];
        console.log('Row:', row);
        
        if (!row) {
            console.error('Row not found');
            frappe.validated = false; // Prevent the row from being removed
            return;
        }
    
        console.log('Row status:', row.status);
    
        if (row.status !== 'Initiated') {
            frappe.msgprint('Cannot remove orders');
            frappe.validated = false; // Prevent the row from being removed
            console.log('Removal prevented');
            return;
        }
    
        // Refresh the field and update the total count
        frm.refresh_field('order_list_table');
    },

You can manage easily in python side:

Example:

DocType Event → Before Save

doc = frappe.get_doc("Sales Order", "SAL-ORD-0001")

for row in doc.items:
    if row.item_code == "ITEM-001":
        doc.remove(row)
        break
1 Like

@NCP But I want to display msg when trying to delete other rows while clicking delete button not allowing to delete that row.
But here it delete that row then show msg which i think is kind of bug in my case.

Also I don’t want to remove all initiated status rows. only selected one

is it possible to achieve from client side?

frappe.throw works!!! :heart_eyes: