Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Possible to add workflow condition for issue deletion ?

AisM
Contributor
October 5, 2023

Hi,

As an admin i want to make sure issues can be deleted by USERS only if certain conditions are met, example - 

1) Users cannot delete an issue if its in the resolved status

2) Users cannot delete an Epic if its child issues are completed

Is it possible to add such a condition in the workflow, so that a prompt shows up when a user tries to delete a resolved issue, similar to a workflow validation prompt

 

4 answers

2 accepted

1 vote
Answer accepted
Antoine Berry
Community Champion
October 10, 2023

Hello @AisM ,

Sorry, busy days...

I agree with what have been answered already.

Consider using a specific resolution, status or project (i. e. archiving) instead of deletion.
That being said,  for the 1st requirement, you can indeed use a property (as said before : jira.permission.delete.denied) on specific statuses ("unresolved" statuses) and set it to true.

To my knowledge, the 2nd requirement is not possible (but I have not looked that far). Of course it would be possible using a condition on a transition if you used a status "Deleted" instead of actually deleting the issues.

You can also refer to this question : https://community.atlassian.com/t5/Jira-questions/Is-it-possible-to-show-the-quot-Delete-quot-button-selectively/qaq-p/1338844

to check the details of the implementation.

AisM
Contributor
October 11, 2023

@Antoine Berry  Understandable !!!! :):) But thank you so so much for looking into it !

The workflow method worked, but the org did not like that approach of touching the workflow 

So, I tried the scriptrunner hide element option to hide for resolved issues & it worked ! 

I want to incorporate two more conditions (hide delete if issue type is program epic & portfolio epic, and also for epics with completed child issues) into the script, but when I do, it doesn't work. Not sure what mistake I'm doing,

import com.atlassian.jira.component.ComponentAccessor

def issue = issue

if (issue.resolutionObject) {
return false
} else {
return true
}
1 vote
Answer accepted
Tom Lister
Community Champion
October 6, 2023

Its not really possible to control the permitted issue actions from the workflow.

The workflow actions are the business logic and not the framework.

I've often restricted who can delete issues in project permissions as deletion errors are a pain. As is explaining to users there is no restore option for their work.

You can control when an issue can be deleted in a workflow via properties

e.g. add jira.permission.delete.denied to statuses

If you create a Delete status in the workflow you could set conditions on how that can be transitioned to. The Delete status could not have the delete denied property so making it available.

AisM
Contributor
October 6, 2023

Thank you for the comment !

Actually, I wanted to make a change to my question. We want to enable the delete feature to the users (Till now, its restricted to admins)

So, I have two conditions,

1) Only unresolved issue can be deleted

2)  Epic with completed child cannot be deleted

So, if a user tries to delete an issue which is resolved, they must get a workflow style prompt that says "Completed issues cannot be deleted"

Is this possible with the mentioned workflow properties ?

Tom Lister
Community Champion
October 10, 2023

I think my answer would be a variation of my first response.

You can widen the access to delete issue permission in the permission scheme.

And also restrict the permission in the status property  jira.permission.delete.denied

Again allow to move to a Delete status, with no property jira.permission.delete.denied, and check on the transition to Delete that your conditions are met.

I don't know of any other ways to dynamically control access to the More/Delete  option.

AisM
Contributor
October 11, 2023

Hi @Tom Lister , Thank you for the comments, I was actually able to try this out with the method you suggested. And it did work too !

But, that just complicated the already complex workflow, So we have dropped modifying the workflow. I am currently planning to hide the delete option through the Script fragments - Hide element option based on the conditions. But, that has its pros & cons too

Like Tom Lister likes this
1 vote
Asha Goyal
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 5, 2023

Hello @AisM ,

Although it is not recommended to delete any issue, if you really want to do so, look at IssueService component and it's methods.

Hope that helps.

Thanks

AisM
Contributor
October 6, 2023

Thank you for the comment. I will look into it.

0 votes
AisM
Contributor
October 8, 2023

Hello @Antoine Berry  Can I pleaseeeeeeeeee get your help on this :( 

Suggest an answer

Log in or Sign up to answer