How to disable delete button from drop down-menu according to condition provided by us

I have some doc status if the status of document is in draft state then only the user should be able to delete the form otherwise the form should not be able deletable. What is the function to hide the delete button according to our condition.


If you are not using the workflow, then there will be three states possible, Draft, Submitted, Cancelled.

Now, play with the permission for Delete and Cancellation to achieve what you want.

If you can post the real-life example, I can give you the exact user permissions need to be setup to achieve the same.

Divyesh Mangroliya

Real life example :
suppose I have a document that has 2 states one draft and another pending approval from the manager. So if the document is in draft state only at that time condition should be applied i.e if the document state is draft then only the delete option should be visible otherwise delete option should be disabled. In other words, suppose as a manager I have a deletion option for the timesheet but I should only be able to delete the document if the state is draft if it is in the pending state I should not delete that document. Now what is happening here is if I have deletion option enabled from role permission manager i can delete the document whichever it has the state. Please help me with this. if you still have confusion feel free to ask
Thank You


As you are using the Workflow and Document will be in the Draft state only till it gets approved, though Workflow state may differ.

Only thing you can do is not allow the delete write to anybody accept Administrator or super user. If any user needs to delete any documents, they need to contact the person with delete write.

Another option is to write a client script to accomplish the same.


Divyesh .

To disable the delete button a dropdown menu based on specific condition, you can use simple function to control its visibility

function hideDeleteButton(documentStatus) {
  const deleteButton = document.getElementById('deleteButton');

  if (documentStatus === 'draft') { = 'none'; // Hide the delete button
  } else { = 'block'; // Show the delete button

In this ex, documentStatus represents the status of the document (e.g. “draft”). If the status is “draft”, the delete button with the ID “deletebutton” will be hidden using CSS