"issue.getSubTaskObjects().size() == 1" groovy condition is not working in cloud.

Hi All ,


I'am trying to create a subtask based on conditional execution. The condition is that if the issue already has one subtask existing then it should create. I'am using the statement/code as follows :

issue.getSubTaskObjects().size() == 1

I tested this in my local SERVER instance and it is working fine. However I could not make it work on my cloud system. Can anybody let me know why its not working ? Also, is there any other way i can validate(apply conditional execution) the subtask count on cloud system?



Thank you!

Swathi Komirelli

2 answers

Hi Swathi,

JIRA Server and JIRA Cloud add-ons work in very different ways. We have written up some documentation around this here: http://scriptrunner-docs.connect.adaptavist.com/jiracloud/ and http://scriptrunner-docs.connect.adaptavist.com/jiracloud/migrating.html

Testing scripts on a JIRA Server instance before using it in JIRA Cloud will not work because ScriptRunner for JIRA Cloud does not have access to the same APIs.

The equivalent JIRA Cloud code to what you have written is:

issue.fields.subtasks.size() == 1

I hope that helps - feel free to ask more questions here or open a support request directly with us: https://productsupport.adaptavist.com/servicedesk/customer/portal/23/create/112


Hi @John Bevan,


Thanks for your inputs.The script you have provided is also not working. I tried other scripts based on the documentation,but none of them seems to work.

I raised a request with your support desk. 




Retagging as @Jon Bevan [Adaptavist].

"Wherever we are, we are as one"

Just as FYI - 


Here is the solution : 


def issueSubTasks = ((List)issue.fields.subtasks).size() ?: 0
if (issueSubTasks ==1)
return true



Suggest an answer

Log in or Join to answer
Community showcase
Bridget Sauer
Published Mar 09, 2018 in Jira Service Desk

E.L. Fridge's take on education, Jira Service Desk, and creative Jira use cases

...word of mouth, so by 2016, we were working with several other entities on campus to implement Jira Service Desk . The Atlassian motto of “for every team” has really come true for us in this case. We...

364 views 0 9
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot