How can I prevent a task from being set to 'Done', while keeping the button visible

Ivan
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
December 16, 2024

Hello community,

In my topic, I want to configure the system so that it’s not possible to set an open task to the status "Done" or "Canceled" if there are still open subtasks.

I know that under the "Triggers" section, you can set the transition to "All subtasks must be done," but here’s the actual problem:

I don’t want the "Done" button to disappear. Instead, I want it to remain visible, and when I click it, there should be a message like "Check open subtasks," for example.

How can I set this up? Does anyone have an idea?

 

(Info --> "Erledigt" = "Done")

Screenshot 2024-12-16 091413.png

Screenshot 2024-12-16 091151.png

Screenshot 2024-12-16 091434.png

3 answers

2 accepted

1 vote
Answer accepted
Tuncay Senturk
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
December 16, 2024

Hi @Ivan 

To achieve this in Jira, you can use a Workflow Validator instead of a Trigger or a condition. A Workflow Validator allows you to check conditions when transitioning an issue, and if the condition isn’t met, it displays an error message while keeping the transition button visible. Workflow condition hides the button when it does not meet the condition.

0 votes
Answer accepted
Cyrille Martin
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.
December 16, 2024

Hi @Ivan 

You can use the Condition on your workflow to do exactly the behavior you explained

Here is the documentation

Sorry not the Condition, but the Validators.

Regards,

0 votes
Ivan
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
December 16, 2024

Hei, @Tuncay Senturk @Cyrille Martin 

thank you guys for the quick answer, but what option should I choose in the Validators option?

Do I have to run my own script and choose the "Custom Script validator"?

Tuncay Senturk
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
December 16, 2024

Edit your workflow and select the transition to the "Done" or "Canceled" status (for example, the transition from "In Progress" to "Done")

Then click on the transition arrow and select Validators.

Add Validator, then select ScriptRunner > Script Validator (I assume you have ScriptRunner)

Use the following Groovy script to check for unresolved subtasks. Please adjust the code to your needs and test it

import com.atlassian.jira.component.ComponentAccessor

def issueManager = ComponentAccessor.getIssueManager()
def subTaskManager = ComponentAccessor.getSubTaskManager()

if (issue.isSubTask()) {
return true
}

def subTasks = issue.getSubTaskObjects()

// Check if any subtask is not in the "Done" status
if (subTasks.any { it.getStatusObject().getName() != "Done" }) {
invalidInputException.addErrorMessage("You cannot transition this issue to 'Done' or 'Canceled' while it has open subtasks.")
return false
}

return true

 

Ivan
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
December 16, 2024

Thank you so much, I tried it with your script and now it works perfectly fine. I already testes it and now I know how to do it by my own. Thank you @Tuncay Senturk !!

Suggest an answer

Log in or Sign up to answer