Restrict subtask issueType options based on it's parent issue issueType

Hi everyone,

I'm trying to restrict available issue types on subtask creation, based on the issue type of it's parent issue. So, for example, for the issue type "Sample", on subtask creation, I want to have only one option "Issue subtask".
So far I've implemented the following script, as an initialiser function on behaviour, and then set it to issueType field:

import static com.atlassian.jira.issue.IssueFieldConstants.ISSUE_TYPE
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.component.ComponentAccessor

Issue parentIssue = underlyingIssue.parentObject

def constantsManager = ComponentAccessor.getConstantsManager()
def sampleIssueType = constantsManager.getAllIssueTypeObjects().find { == "Sample" }

    def issueSampleIssueType = constantsManager.getAllIssueTypeObjects().find { == "Issue subtask" }

    // In other cases, I'll need multiple options

    getFieldById(ISSUE_TYPE).with {

However, it is not working as expected (all issue types are available when I create a subtask of "Sample")

Can someone please help me on that?

Thanks in advance,

2 answers

Hi Rodrigo,

Your code should work if you remove the .parentObject from the underlyingIssue.

Just use underlyingIssue.

Let me know if that works.


Johnson Howard

Hi Johnson, thanks for your help.

I've removed the, .parentObject, but it stills not working ...

Is there any full reference available, listing all available variables on that context (field initialization) such as "underlyingIssue"? I Know that there are some examples online using that variable, but a full reference would be great.

Also, "formField.setFieldOptions(Iterable)" seems to not work with collections (which is exactly the example showed on edit screen), how can I use this function (I'll need to allow multiple values for subtask issue type, based on parent's issue type)?


As it turns out, question is well warented and today I learned that this is actually a known bug in our current ScriptRunner back-log. You can go here -> SRJIRA-1010 - to see more details on the bug, I'm sorry I wasn't able to catch this before putting you through the additional trauma of creating a question on the Atlassian Community.

Gonchik Tsymzhitov Community Champion Thursday


@Aidan Derossett [Adaptavist] Do you know any plans to fix it? 



Gonchik Tsymzhitov

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Monday in Jira Software

How large do you think Jira Software can grow?

Hi Atlassian Community! My name is Shana, and I’m on the Jira Software team. One of the many reasons this Community exists is to connect you to others on similar product journeys or with comparabl...

418 views 6 10
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