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,456,701
Community Members
 
Community Events
176
Community Groups

Need to hide issue types from issue type drop down

I have two sub task types - Subtask and Defect subtask . The Defect subtask is  for Bug issue  and Sub-task is  for all other issue type. When ever I click On the Create subtask screen , both  Sub task and Defect  issue type get populated from the Issue type drop down. I  would like to  hide the Sub task and make it Defect when  I  create a defect subtask under the Bug issue type.

 

 create bug issue type-> click on the create a sub task-> Create sub task screen is displayed. In the drop down on the Create subtask screen I see sub task and defect sub task both. I have tried to hide the sub task .But I am not able to. If I make defect subtask read only using the behavior plugin, it is affecting all other Create subtask screen for other issue types(EPIC , User story , task). How do I handle this in Create sub task screen.

Is there a way to create new create subtask screen for Defect subtask (issue type)

 

1 answer

1 vote

Hi

Welcome to the Atlassian Community.

I don't think you need to build new screens etc.

You can use behaviour to manipulate the list of issue types offered  in the drop down.

The trick is that you need to get information about the parent issue (to know which issue type to show or hide).

And you'll want to make sure that the behaviour only fires when a sub-task is being created (not the parent issues).

Try something like this (in the initializer of a behaviour for your project either mapped to all issue types or just the 2 sub-tasks)

import com.atlassian.jira.component.ComponentAccessor

if(issueContext.issueType.isSubTask()){ //this may not be needed if the behaviour mapping is only for the sub-tasks
def issueTypeField = getFieldById('issuetype')
def parentIssueIdFld = getFieldById('parentIssueId')
def parentIssue = ComponentAccessor.issueManager.getIssueObject(parentIssueIdFld.value as Long)
def allIssueTypes = ComponentAccessor.constantsManager.allIssueTypeObjects

def subtaskName

if(parentIssue.issueType.name == 'Bug'){
subtaskName = 'Defect'
} else {
subtaskName = 'Sub-task'
}
issueTypeField.setFieldOptions(allIssueTypes.findAll{it.name == subtaskName})
issueTypeField.setFormValue(allIssueTypes.find{it.name == subtaskName}.id)
}

Thank you this code actually worked. It tested it further and added a new subtask by name ' Test Sub-task' , I went ahead and created a create subtask under bug issue type and on the create sub task screen , under the Issue type drop down , I was able to select  the Newly created 'Test Sub-task' from the Issue type drop down. I believe any time a new subtask is added , The new subtask will be displayed under the issue type drop down. How do I handle this issue in future any time a new subtask type is added. 

I would like Bug issue type(Parent issue) to have only  'Defect' Sub task associated with it all the time even if a new Subtask like ' Test Sub- task ' created.

I have hidden behavior to  'Sub-task' subtask in the Script runner  UI Hide element behavior.

If you want defect for Bug and all-but defect for non-bug, then the flow of the script could look a little like this:

def allowedSubtasks = []
if(parentIssue.issueType.name == 'Bug'){
allowedSubtasks = allIssueTypes.findAll{it.name == 'Defect'}
//since there is only 1 available subtaks, might as well select it
issueTypeField.setFormValue(allowedSubtasks[0].id)
} else {
allowedSubtasks = allIssueTypes.findAll{it.name != 'Defect'}
}
issueTypeField.setFieldOptions(allowedSubtasks)

Garden16,

How to add more subtasks to the code? I try to add one more subtask with another name and I can't.

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events