Hello All,
We have Organized Jira Service desk Request Types to multiple Groups to appear in the customer portal Ex: Jira, Confluence, Bitbucket and Bamboo.
Each Group has multiple Request types For Example: Jira has following Request types New Account, modify Field, Edit Project Reporting and Bug.
Group confluence has following Request types New Confluence Space, Additional functionality, Bug and Performance
For Groups Jira and confluence has following fields on Customer portal Summary, Description, Attachment and Servers. Servers custom field has following Options Server1, Server2, Server3 and Server4.
Now we want to Restrict the values on the Servers field depend on the Request Type group. Ex - If user selects a Group Jira and Request name Bug on the customer portal Servers field
has to show following options Server1 and Server2 and same way if user selects Confluence group and Request name Bug Servers field has to show only following options Server 2 and Server 3.
To achieve this we have added below script in the behavior and mapped to Jira service desk project and All Request Types. But Servers custom field is showing all 3 options in Groups Jira , Confluence, BitBucket and Bamboo in Bug request type which we added in the script.
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.customfields.option.Option
def issueField = getFieldByName("Servers")
// Get the current user
def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def optionsManager = ComponentAccessor.getOptionsManager()
def customField = customFieldManager.getCustomFieldObject(issueField.fieldId)
def config = customField.getRelevantConfig(getIssueContext())
// Get predifined customField options
def options = optionsManager.getOptions(config)
def groupProjectsMap = [
'Jira': ['Server1','Server2'],
'Confluence': ['Server3'],
]
def optionsToSet = []
log.debug("Map: ${groupProjectsMap}")
for (r in groupProjectsMap) {
def option = options.findAll {it.value in r.value} as List<Option>
optionsToSet.add(option)
}
log.debug("Options: ${optionsToSet.flatten()}")
issueField.setFieldOptions(optionsToSet.flatten())
Please help!
Thanks in advance,
Ch