Hello All,
We have created different Groups(1, 2, 3) in Service desk project Request types and Group 1 and Group 2 has a custom field called Tools with options Jira, Confluence, & Bitbucket.
In custom portal if customer selects a Group 1, Tools custom field should display only Jira and confluence options if he selects Group 2 it has to display only Jira and Bitbucket options.
To achieve this i have added below script in the behavior. But it is restricting values to all groups in the Request type. i am new to groovy script.
import com.atlassian.jira.component.ComponentAccessor
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def optionsManager = ComponentAccessor.getOptionsManager()
def formField = getFieldByName("Tools") // update FIELD_NAME with your custom field name
def customField = customFieldManager.getCustomFieldObject(formField.getFieldId())
def config = customField.getRelevantConfig(getIssueContext())
def options = optionsManager.getOptions(config)
// update below OPTION_ONE, OPTION_TWO, OPTION_THREE with desired options
// note the options listed need to first be configured within the full project field context and must match exactly
def optionsMap = options.findAll {
it.value in ["Jira", "Confluence", "Bitbucket"]
}.collectEntries {
[
(it.optionId.toString()) : it.value
]
}
formField.setFieldOptions(optionsMap)
Please help!
Thanks in advance,
Ch