How to script a default issue type for a project

I am trying to use behavior in  script runner to default to a particular issue type. However, when I try to do with following code, though it defaults to the required issue type "ABC", it does not allow any other issue type to be selected. Please let me know what modifications are required in the code.

import com.atlassian.jira.component.ComponentAccessor

import static com.atlassian.jira.issue.IssueFieldConstants.ISSUE_TYPE
def constantsManager = ComponentAccessor.getConstantsManager()
    def queryIssueType = constantsManager.getAllIssueTypeObjects().find { == "ABC" }
   def  IssueType = getFieldById(ISSUE_TYPE)

3 answers

Why not use the default issue setting in the issue type scheme for the project?

Because as per design of jira, it remembers the last Issue Type you used and defaults to this one the next time you create an issue.

I am no expert on scriptrunner but I think what this code is doing is setting the value of the dropdown to your issue type. This would overwrite the values (i.e. all your issues types) that were previously there.

But what you really want is to set the default option value for the drop down which is done via the optionsManager.

I think you should try to do what is described here.


0 votes

You can't really do this with behaviours. Every time the issue type changes, it will load and apply any behaviours for that project and issue type combination. This is because you can assign behaviours to just certain issue types.

So when you change the issue type, it fires, and changes it back.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published yesterday in Jira Ops

Jira Ops Early Access Program Update #1: Announcing our next feature and a new integration

Thanks for signing up for Jira Ops! I’m Matt Ryall, leader for the Jira Ops product team at Atlassian. Since this is a brand new product, we’ll be delivering improvements quickly and sharing updates...

300 views 0 6
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