I am trying to use Behaviors in conjunction with Project/Issue Type context--all the options are in one context with a project/issue type mapping. The goal is to turn off checkboxes in a multi-select field based on project mapping and issue type, but nothing we do seems to work on the Create screen. Once you click on a checkbox however the behavior works as expected, but, NOT when the page loads initially.
I have seen several examples of the code with slight syntactical variations posted across Jira newsgroups. I've tried them but they all produce the same result. Nothing will change the length of the multi-select field on the Create screen based on Issue Type.
But to reiterate, it does work on the Edit and View screens. Just not on the Create screen, unless that is you select one of the checkboxes. Then it works. Any help would be greatly appreciated. We are using Jira 7.10.x. I've tried setting the Field in the Behavior to both Fieldname and IssueType, but neither of those options worked either.
Here's the server-side script snippet.
import com.atlassian.jira.component.ComponentAccessor
def cFManager = ComponentAccessor.getCustomFieldManager()
def oManager = ComponentAccessor.optionsManager
def envType = customFieldManager.getCustomFieldObject(getFieldChanged())
def config = envType.getRelevantConfig(getIssueContext())
def options = oManager.getOptions(config)
def selectcf = getFieldByName("FieldName")
if (getIssueContext().getIssueType().getName() == "Issue Type 1") {
def optionsMap = options.findAll {
it.value in ["VALUE1","VALUE2",] // list of options to show
}.collectEntries {
[
(it.optionId.toString()): it.value
]
}
selectcf.setFieldOptions(optionsMap)
}
else if (getIssueContext().getIssueType().getName() == "Issue Type 2")
{
def optionsMap = options.findAll {
it.value in ["VALUE3", "VALUE4"] // list of options to show.
}.collectEntries {
[
(it.optionId.toString()): it.value
]
}
selectcf.setFieldOptions(optionsMap)
}
Never mind. I figured out a workaround. Works just fine now.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Atlassian Government Cloud has achieved FedRAMP Authorization at the Moderate level! Join our webinar to learn how you can accelerate mission success and move work forward faster in cloud, all while ensuring your critical data is secure.
Register NowOnline 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.