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
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.
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, zUser 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?
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.
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.htmlI 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().namedef 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)}
It looks like you're new here. Sign in or register to get started.