Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

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
4,559,397
Community Members
 
Community Events
184
Community Groups

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 { it.name == "Sample" }

if(parentIssue.getIssueType().equals(sampleIssueType)){
    def issueSampleIssueType = constantsManager.getAllIssueTypeObjects().find { it.name == "Issue subtask" }

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

    getFieldById(ISSUE_TYPE).with {
        setFormValue(issueSampleIssueType.id)
        setReadOnly(true)
    }
}

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,

3 answers

0 votes
Adolfo Casari
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
Feb 14, 2019

@Rodrigo SilvaHi, were you able to resolve this somehow?

Hi @adam_gadomski , this issue was marked as fixed by Adaptavist.
However, I didn't have time to test it yet. You can try something, using this documentation : https://scriptrunner.adaptavist.com/5.4.47/jira/recipes/behaviours/restricting-issue-types.html#_restricting_available_issue_types

And this is the issue https://productsupport.adaptavist.com/browse/SRJIRA-1010

I'll appreciate your feedback, after the test  =)

Good luck,

0 votes
Aidan Derossett _Adaptavist_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
Apr 13, 2017

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 Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 17, 2018

Hi! 

@Aidan Derossett _Adaptavist_ Do you know any plans to fix it? 

 

Cheers,

Gonchik Tsymzhitov

0 votes
JohnsonHoward
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
Apr 13, 2017

Hi Rodrigo,

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

Just use underlyingIssue.

Let me know if that works.

Regards,

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)?

Thanks,

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events