Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Checklist Custom Field - Different options depending on Issue Type possible?

Andreas Denzler
Contributor
September 16, 2020

Hello everyone,

I have a custom field of type checklist.
I want this field to offer different select options, depending on the selected issue type of the issue.
Is this possible and if yes, how?

Thank you!
Best regards,
Andreas

2 answers

0 votes
Gustavo Félix
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.
September 17, 2020

Hi @Andreas Denzler 
I've seen that you have ScriptRunner, so I'd suggest using behaviors.

This is a basic example that you can modify as you wish.
If issueType is task, then it sets only "yes" or "no". 
If is another issueType it would set all the available options.
In your case, just add another if for another issueType, etc...

https://scriptrunner.adaptavist.com/5.6.8/jira/behaviours-overview.html
I add the behaviour to a customField "select" and this code on the server-side script.
I also specify in mapping the project that I wanted.

Please let me know if this helps you.

import com.atlassian.jira.component.ComponentAccessor

def issueType = getIssueContext().getIssueType().name
def selectField = getFieldByName("select")
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def customField = customFieldManager.getCustomFieldObject(selectField.getFieldId())

def config = customField.getRelevantConfig(getIssueContext())
def options = ComponentAccessor.getOptionsManager().getOptions(config)

if(issueType.contains("Task"){
   def optionsToSelect = options.findAll { it.value in ["yes","no"] }
   selectField.setFieldOptions(optionsToSelect)
}else{
         selectField.setFieldOptions(options)
}

0 votes
John Funk
Community Champion
September 16, 2020

Hi Andreas,

Yes, you can do that by adding different Contexts to the custom field. 

Go to Settings > Issues > Custom Fields

Search for your Custom Field

Click on the ellipsis menu (3 dots) on the right hand side and select Contexts and default value

Then click on Add new context link

There you can create a new context and attach it to a particular Issue Type (and project if need be). Then you can add the different values for that issue type. 

Andreas Denzler
Contributor
September 16, 2020

Hi John,

thank you for your help.

I think unfortunately I did not completely explain my problem exactly:

I want the different options in the same project for the same custom field.

Example (always the same field in the same project):

User selects Issue Tpye A: Options are x, y, z
User selects Issue Type B: Options are u, v, w

Unfortunately this can not be done with different contexts, because there is only one context possible for each project.

I think this has to be done by some scripting, e.g. by scriptrunner, which we have installed in our Jira.

How can I do this?

John Funk
Community Champion
September 16, 2020

Yes, I didn't realize that it would be limited to one project. I don't know what you cannot do a combination of Project and Issue Type for for the same project - that's a real drawback. 

Like JIRA Support likes this

Suggest an answer

Log in or Sign up to answer