Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

Jira Expressions in Workflow Validators

I'm having an issue with Jira Expressions. I'm unclear on how to use if statements.

Goal: I've got an issue type of "Groundwork" that uses a workflow that is standard for all subtasks. When this groundwork status is updated to "Complete", I want to check that all sibling subtasks are assigned (because this is just part of the responsibilities for the person who completes the groundwork task). If any are Unassigned this transition should fail.

Steps Taken:


  • I'm unsure how to really use functions or if statements in Jira Expressions. I'm getting the following error and I'm unsure how to translate this into Jira Expressions. Error: "Jira expression failed to parse: line 3, column 1:\nexpression expected, reserved keyword 'if' encountered."
passesCondition = true

// if issue is groundwork type
if ('^(Groundwork)$') != null) {

// get parent
parentIssue = issue.parent

// get subtasks
def subTasks = parentIssue.getSubTaskObjects()

// for each subtask
subTasks.each {
// if not assigned
if (it.assignee == null)
passesCondition = false


1. How can I translate the code above to Jira Expressions?
2. Are there any other alternatives, without Jira Automation?


2 answers

1 accepted

3 votes
Answer accepted

Final answer:

If issue type is not Groundwork, automatically pass, otherwise, check sibling subtasks and assignee.'^(Groundwork)$') == null || ('^(Groundwork)$') != null && issue.parent.subtasks.filter(subtask => subtask.assignee != null).length == issue.parent.subtasks.length)? true : false
0 votes

Hi @perla_miranda  Kindly create a separate workflow for issue type "Groundwork" and apply following script in scripted validator on Complete transition :- 

  issue.subtasks.filter(subtask => subtask.assignee != null).length == issue.subtasks.length

Type an error message to show when the validator fails.



@Vikrant Yadav Can you elaborate on this?

Groundwork is a "subtask" issue type, so this issue will not have any subtasks. I need to check that the siblings are assigned.

Also, the workflow is exactly the same as all other subtasks, so would I need to create a different workflow just to add a validator? Is there no way to check this with if statements?

The solution of duplicating a workflow just for a validator doesn't seem ideal. The Jira expression documentation mentions the following code for checking issue type:'^(Groundwork)$')!= null

  I'm just unsure how to use this in combination with the other things that I need.

Vikrant Yadav Community Leader Aug 22, 2022

@perla_miranda  Okay, i thought "Groundwork" is a Parent task. 

Groundwork is subtask issue type, you want to check that all subtasks  of "Groundwork" subtask issue type only must be assigned before moving to complete status, right ? 

No. Please look at the details in the post. Here is an explanation. Groundwork is a subtask. There are other sibling subtasks.

For example:

- Parent Issue
       - Groundwork subtask (when this is marked as complete, check that all other sibling subtasks are assigned)
       - subtask
       - subtask

Vikrant Yadav Community Leader Aug 24, 2022

@perla_miranda  Checked with Atlassian experts and documents, it's not possible to add if statement in JIRA expression. Meanwhile i suggest you to create a separate workflow for Groundwork issue type and apply above scripted validator. 


I took the code you mentioned before and modified it. I ended up doing the following which works. No need for a separate workflow since all subtasks use the same one and Groundwork is a subtask. Thanks!'^(Groundwork)$') == null || ('^(Groundwork)$') != null && issue.parent.subtasks.filter(subtask => subtask.assignee != null).length == issue.parent.subtasks.length)? true : false


Like # people like this
Vikrant Yadav Community Leader Aug 24, 2022

@perla_miranda  Great 😊 , Finally you made it. 

Suggest an answer

Log in or Sign up to answer
Site Admin

Atlassian Community Events