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