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")
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.
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,
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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"?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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 !!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hei @Tuncay Senturk Sorry for bothering you again, but how do I rewrite the script so that not only the sub-task is checked, but also the task "Genehmigungsaufgabe"?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
import com.atlassian.jira.component.ComponentAccessor
def issueManager = ComponentAccessor.getIssueManager()
def subTaskManager = ComponentAccessor.getSubTaskManager()
// Prüfen, ob das aktuelle Issue ein Sub-Task ist → Kein Check nötig
if (issue.isSubTask()) {
return true
}
// Alle Sub-Tasks abrufen
def subTasks = issue.getSubTaskObjects()
// 1. Filtern nach Sub-Tasks vom Typ "Genehmigungsaufgabe"
def approvalTasks = subTasks.findAll { it.getIssueType().getName() == "Genehmigungsaufgabe" }
// Prüfen, ob eine "Genehmigungsaufgabe" noch im Status "Open" ist
if (approvalTasks.any { it.getStatusObject().getName() == "Open" }) {
invalidInputException.addErrorMessage("You cannot close this issue while any 'Genehmigungsaufgabe' is still in the 'Open' status.")
return false
}
// 2. Prüfen, ob alle Sub-Tasks (außer Genehmigungsaufgaben) im Status "Done" sind
def remainingSubTasks = subTasks - approvalTasks // Sub-Tasks ohne "Genehmigungsaufgabe"
if (remainingSubTasks.any { it.getStatusObject().getName() != "Done" }) {
invalidInputException.addErrorMessage("You cannot close this issue while some subtasks are not in the 'Done' status.")
return false
}
return true
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Please double-check.
import com.atlassian.jira.component.ComponentAccessor
def issueManager = ComponentAccessor.getIssueManager()
def subTaskManager = ComponentAccessor.getSubTaskManager()
// Get the issue type of the current issue
def issueTypeName = issue.getIssueType().getName()
// Check if the current issue is of type "Genehmigungsaufgabe"
if (issueTypeName == "Genehmigungsaufgabe") {
// Check if the current "Genehmigungsaufgabe" issue is in the "Open" status
if (issue.getStatusObject().getName() == "Open") {
invalidInputException.addErrorMessage("This 'Genehmigungsaufgabe' cannot be closed while it is in the 'Open' status.")
return false
}
}
// If the issue is not a sub-task, check its sub-tasks
if (!issue.isSubTask()) {
// Alle Sub-Tasks abrufen
def subTasks = issue.getSubTaskObjects()
// 1. Filtern nach Sub-Tasks vom Typ "Genehmigungsaufgabe"
def approvalTasks = subTasks.findAll { it.getIssueType().getName() == "Genehmigungsaufgabe" }
// Prüfen, ob eine "Genehmigungsaufgabe" noch im Status "Open" ist
if (approvalTasks.any { it.getStatusObject().getName() == "Open" }) {
invalidInputException.addErrorMessage("You cannot close this issue while any 'Genehmigungsaufgabe' sub-task is still in the 'Open' status.")
return false
}
// 2. Prüfen, ob alle Sub-Tasks (außer Genehmigungsaufgaben) im Status "Done" sind
def remainingSubTasks = subTasks - approvalTasks // Sub-tasks excluding "Genehmigungsaufgabe"
if (remainingSubTasks.any { it.getStatusObject().getName() != "Done" }) {
invalidInputException.addErrorMessage("You cannot close this issue while some sub-tasks are not in the 'Done' status.")
return false
}
}
// If all checks pass, allow the transition
return true
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.