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 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)
}
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.