How to let some user delete the doc in there role just in workflow



I have this workflow
and the delete permission is just assigned to the accounts user and this user has write and draft status
It’s supposed to be that the user that has the role accounts user can delete if the doc status is write or draft
but the is that the user could delete ether the doc if its status is save too

Please check the role of Save, the role is auditor … something, you have to add the delete role from the Role Permission Manager.

i need just delete if the doc status is write or draft just
not the save status

To develop this scenario, you’ll need a combination of client and server scripts.

how?
what is the client and server scripts i need

Sample code:

frappe.ui.form.on('Your DocType', {
    refresh: function(frm) {
        if(frm.doc.workflow_state != "Save") {
            frm.page.menu.find('[data-label="Delete"]').parent().parent().remove();
        }
    }
});

does not work with me?

Please set your doctype name and set it. it’s just a sample code.

i change the

with my doctype
and the condition is that

if(frm.doc.workflow_state == "Save") {
but this work in English but in Arabic does not work


in English worked

frappe.ui.form.on('Journal Entry', {
	refresh(frm) {
		 if(frm.doc.workflow_state == 'Save') {
		     frm.page.menu.find('[data-label= '+ __("Delete") +']').parent().parent().remove();
		     frm.page.menu.find('[data-label="%D8%AD%D8%B0%D9%81"]').parent().parent().remove();
        }
	}
})

for both languages
@NCP thanks