Created
April 27, 2021 05:58
-
-
Save vikrantyadav11/8698b2eff93b104041df8c8c9314394c to your computer and use it in GitHub Desktop.
Set custom field value based on Issue type selection using Script Runner behavior
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.atlassian.jira.component.ComponentAccessor | |
import com.atlassian.jira.issue.* | |
def issuetype = getIssueContext().getIssueType().name | |
def selectcf = getFieldByName("Sub-type") | |
selectcf.setFormValue(null) | |
def customFieldManager = ComponentAccessor.getCustomFieldManager() | |
def optionsManager = ComponentAccessor.getOptionsManager() | |
def customField = customFieldManager.getCustomFieldObject(selectcf.getFieldId()) | |
def config = customField.getRelevantConfig(getIssueContext()) | |
def options = optionsManager.getOptions(config) | |
if (issuetype.contains("Custom Product")) { | |
def optionsMap = options.findAll { | |
it.value in ["Custom Requests","Survey Project Management","Proposals"] | |
}.collectEntries { | |
[ | |
(it.optionId.toString()): it.value | |
] | |
} | |
selectcf.setFieldOptions(optionsMap) | |
} | |
else if (issuetype.contains("Data Innovations")) { | |
def optionsMap = options.findAll { | |
it.value in ["Comp. Tool Technical Help"] | |
}.collectEntries { | |
[ | |
(it.optionId.toString()): it.value | |
] | |
} | |
selectcf.setFieldOptions(optionsMap) | |
} | |
else { | |
def optionsMap = options.findAll { | |
it.value in ["Job Matching Assistance Only", "Standard Data Extract","Job Matching and Data Extract","Prevailing Wage"] | |
}.collectEntries { | |
[ | |
(it.optionId.toString()): it.value | |
] | |
} | |
selectcf.setFieldOptions(optionsMap) | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment