Hi All I want to Hide the Delete & Edit button in Lead, CRM Note Screen.
With Below Code, I am able to Hide it When the form is loaded, but whenever I add or remove any Note, the button shows up again
frappe.ui.form.on('Lead', {
onload: function(frm) {
// Initial hiding of buttons
hide_note_buttons(frm);
// Ensure buttons are hidden when notes are refreshed
frm.fields_dict.notes.grid.wrapper.on('click', '.grid-add-row, .grid-remove-rows', function() {
setTimeout(() => {
hide_note_buttons(frm);
}, 500);
});
},
refresh: function(frm) {
// Hide buttons on refresh
setTimeout(() => {
hide_note_buttons(frm);
}, 500);
}
});
function hide_note_buttons(frm) {
// Get the current user
var current_user = frappe.session.user;
// Iterate through the notes and hide buttons for non-owners
$('.comment-content').each(function() {
var added_by = $(this).find('.head .title').text().trim();
if (added_by !== current_user) {
// Hide the edit button
$(this).find('.edit-note-btn').hide();
// Hide the delete button
$(this).find('.delete-note-btn').hide();
}
});
// Hide the "Done" button in modal forms
$('.standard-actions .btn-modal-primary').each(function() {
var buttonText = $(this).text().trim();
if (buttonText === 'Done') {
$(this).hide();
}
});
}
Help me implement this functionality, A New approach is also welcome.
Thanks in advance