Hi all,
Our users would want to have this set up: when the value "Cognizant Team" in the custom field "Assigned Team" is selected, the system field "Link Issue" will only show the value "is blocked by" and so on.
I think this should be feasible with Behaviours of Scriptrunner, as we already had a similar behaviour, but that was for 2 custom fields. I'm not sure how the script should be when 1 field is system field. Here is what I got so far:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.fields.CustomField;
import com.atlassian.jira.issue.CustomFieldManager;
def mappingList = [
'None': [
'None'
],
'Cognizant Team': [
'is blocked by'
],
'Migration Leads': [
'relates to'
]
]
def assignedteamMappingList = mappingList.keySet() as List
def assignedteamCF = getFieldByName("Assigned Team")
def assignedteamValue = assignedteamCF.getValue()
def linktypeSF = getFieldById("issuelinks-linktype")
def linktypeValue = linktypeSF.getValue()
def listOptions = mappingList.get(assignedteamValue)
def optionsManager = ComponentAccessor.getOptionsManager()
def assignedteamCustomField = customFieldManager.getCustomFieldObjectsByName("Assigned Team")[0]
def assignedteamFieldConfig = assignedteamCustomField.getRelevantConfig(issueContext)
def assignedteamOptions = optionsManager.getOptions(assignedteamFieldConfig)
def assignedteamOptionsMap
if (assignedteamMappingList != []){
assignedteamOptionsMap = assignedteamOptions.findAll {
it.value in assignedteamMappingList
}.collectEntries {
[(it.optionId.toString()) : it.value]
}
assignedteamCF.setFieldOptions(assignedteamOptionsMap)
}
Appreciate all the help.
Thank you,
Duong