I created a workflow for it.
How can I delete it from the list !?
If workflow is enabled, then you can’t bulk delete or edit the record.
frappe.listview_settings['Your Doctype'] = {
hide_name_column: true,
onload: function(listview) {
listview.page.add_action_item(__('Delete Selected'), function() {
let selected_docs = listview.get_checked_items();
if (selected_docs.length > 0) {
frappe.confirm(
__('Are you sure you want to delete these {0} records?', [selected_docs.length]),
function() {
let failed_deletions = [];
let delete_count = 0;
selected_docs.forEach(doc => {
frappe.call({
method: 'frappe.client.delete',
args: {
doctype: 'Your Doctype',
name: doc.name,
},
callback: function(response) {
delete_count++;
// Check if there was an exception (failed deletion)
if (response && response.exc) {
failed_deletions.push(doc.name);
}
// When all requests are processed
if (delete_count === selected_docs.length) {
if (failed_deletions.length > 0) {
frappe.msgprint(__('Failed to delete the following records: {0}', [failed_deletions.join(", ")]));
} else {
frappe.msgprint(__('All selected records were deleted successfully.'));
}
listview.refresh();
}
},
error: function(err) {
failed_deletions.push(doc.name);
delete_count++;
// Handle all records processed
if (delete_count === selected_docs.length) {
if (failed_deletions.length > 0) {
frappe.msgprint(__('Failed to delete the following records: {0}', [failed_deletions.join(", ")]));
} else {
frappe.msgprint(__('All selected records were deleted successfully.'));
}
listview.refresh();
}
}
});
});
}
);
} else {
frappe.msgprint(__('Please select records to delete.'));
}
});
}
};
1 Like