How to Avoid Accidental Deletion of a Jira Issue?

If you’d like to avoid accidental Jira issue removals or transitions in case they have some other issues linked to it, then do following:

  1. Never allow users to delete Jira issues. Remove this permission from projects permission schemes and use “Resolutions” and statuses to illustrate the deletion process instead. For example, you may have “Deleted”, ”Canceled” or similar status in your workflow instead or you may have a special Resolution called “Deleted” so that when you resolve issues you can select the resolution from the list. This will allow you to have all history of all user deleted Issues in a specific (searchable) status.

  2. In order to not accidentally transition issues from one state to another use workflow Validators (read more at Advanced workflow configuration by Atlassian.

  • First create validation script. The following validation script will block transition (read - delete or remove issue from the desired status to a new one), if the linked issue (with link type “Risk Mitigation“) isn’t in the desired status (“New Risk” or “Mitigated”). Now, if you apply this validator to your workflow, you cannot accidentally delete these issues!

// Statuses that does not allow us to delete/transition current issue string[] linked_issues_in_statuses = {"New Risk", "Mitigated"}; string errorMsg = "Progress can't start because there is at least one linked issue in incorrect status."; if (!size(linkedIssues(key)) == 0) { //take all links by link type "Risk Mitigation" with direction "mitigates" //-1, 0, 1 :Negative means inward links. Positive means outward links. Use zero to get both outward and inward links. string[] linkedIssues = linkedIssues(key, "Risk Mitigation", 1); if (size(linkedIssues)>0) { for(string issue in linkedIssues) { if(elementExists(linked_issues_in_statuses, %issue%.status)) { return false, errorMsg; } } } }
  • Second, add the SIL Validator to the workflow transition you need. Use the previously created script in this validator.

and you will see the following message when trying to execute the forbidden transition:

Success!