← All posts

Jira

Jira ScriptRunner Validator: Block Parent Issue Transition Until Subtasks Are Completed

Ziad Bakhiet/Sep 8, 2025/3 min read

Learn how to use a ScriptRunner validator in Jira to block parent issue transitions until specific subtasks are marked as Done.

Jira ScriptRunner Validator: Block Parent Issue Transition Until Subtasks Are Completed

Introduction

One common workflow requirement in Jira is ensuring that parent issues cannot progress until all subtasks are completed.
This safeguard helps maintain proper process controls and prevents data inconsistencies.

This article walks through how to implement a ScriptRunner workflow validator that blocks a parent issue transition unless its subtasks of a specific type are marked as Done.

This scenario is typical in workflows where managers or teams need better control over issue progressions.


Why Use a ScriptRunner Validator?

Jira’s built-in validators handle basic workflow conditions but often cannot enforce conditional checks on subtasks.
ScriptRunner enables:

  • Custom logic for parent-child issue relationships
  • Detailed error messages shown to users during transitions
  • Enforcement of process compliance in complex workflows

For example:

  • A Parent Task issue should only transition forward when all its Review subtasks are completed.
  • If any Review subtask is still “In Progress,” the parent must remain in its current status.

The ScriptRunner Validator Script

Below is a generic Groovy script you can use as a Custom Script Validator in your Jira workflow:

import com.atlassian.jira.component.ComponentAccessor
import com.opensymphony.workflow.InvalidInputException

// Only apply logic if parent is of a specific issue type (replace "Parent Task" with your type)
if (issue.issueType.name == "Parent Task") {

    // Retrieve all subtasks of this issue
    def subtasks = issue.subTaskObjects

    // Filter subtasks by a specific issue type (replace "Review" with your subtask type)
    def reviewSubTasks = subtasks.findAll { it.issueType.name == "Review" }

    // If no matching subtasks exist, allow the transition
    if (!reviewSubTasks) {
        return true
    }

    // Find subtasks that are not done
    def notDoneSubTasks = reviewSubTasks.findAll { it.status.name != "Done" }

    if (notDoneSubTasks) {
        def openList = notDoneSubTasks.collect { "${it.key} (${it.summary})" }.join(", ")
        throw new InvalidInputException("Cannot transition parent issue. The following Review subtasks are not Done: ${openList}")
    }
}

This ScriptRunner validator script is intended for Jira Data Center environments.

This script ensures:

  • Transition is blocked if any Review subtasks are still open
  • Transition is allowed if all Review subtasks are Done
  • If no Review subtasks exist, the validator does not block the transition

Step-by-Step Setup in Jira

To add this validator to your workflow:

  1. Go to Project Settings → Workflows
  2. Select the workflow for your parent issue type (e.g., "Parent Task")
  3. Edit the workflow and select the transition you want to validate
  4. Click Validators → Add Validator → ScriptRunner Script Validator
  5. Paste the generic script above and publish your workflow
  6. Test by trying to transition a parent issue with incomplete subtasks

Common Mistakes to Avoid

When adding this type of validator, avoid these pitfalls:

  • ❌ Applying the rule to all parent issues without filtering by issue type
  • ❌ Providing empty or unclear error messages that confuse users
  • ❌ Hardcoding status or issue type names inconsistently across projects

Addressing these helps ensure users understand why transitions are blocked and avoid workflow frustration.


Real-World Use Cases

  • IT Change Management: Prevent a parent task from advancing until all reviews are complete
  • Quality Assurance: Block deployment tickets until all test subtasks are closed
  • Compliance: Ensure all audit subtasks are finalized before approval

Teams who use this pattern report fewer errors, improved compliance, and clearer audit trails.


Final Thoughts

ScriptRunner validators unlock powerful workflow controls in Jira with minimal scripting. They help enforce policies aligned with organizational best practices such as ITIL or DevOps.

If looking to optimize Jira workflows or design governance frameworks:
👉 Contact me for expert Atlassian consulting

Subscribe for more Atlassian automation ideas and real-world tips and strategies.