This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
script_fields [2017/07/17 15:25] pawel [Update custom field] |
script_fields [2019/07/11 09:28] (current) root |
||
---|---|---|---|
Line 35: | Line 35: | ||
setSummary(" | setSummary(" | ||
</ | </ | ||
+ | |||
+ | |||
+ | ==== Drop Down Values based on Transitions ==== | ||
+ | Create this as an initialiser. | ||
+ | <code java> | ||
+ | import com.atlassian.jira.component.ComponentAccessor | ||
+ | import static com.atlassian.jira.issue.IssueFieldConstants.* | ||
+ | |||
+ | def customFieldManager = ComponentAccessor.getCustomFieldManager() | ||
+ | def optionsManager = ComponentAccessor.getOptionsManager() | ||
+ | |||
+ | def formField = getFieldByName(" | ||
+ | def customField = customFieldManager.getCustomFieldObject(formField.getFieldId()) | ||
+ | def config = customField.getRelevantConfig(getIssueContext()) | ||
+ | def options = optionsManager.getOptions(config) | ||
+ | |||
+ | // Set the values inside the select list field | ||
+ | def noneMap = [" | ||
+ | |||
+ | |||
+ | if (getActionName() == "Need More Info") { | ||
+ | def optionsMap = noneMap + options.findAll { | ||
+ | it.value in [" | ||
+ | }.collectEntries { | ||
+ | [ | ||
+ | (it.optionId.toString()) : it.value | ||
+ | ] | ||
+ | } | ||
+ | formField.setFieldOptions(optionsMap) | ||
+ | } else if (getActionName() == " | ||
+ | def optionsMap = noneMap + options.findAll { | ||
+ | it.value in [" | ||
+ | }.collectEntries { | ||
+ | [ | ||
+ | (it.optionId.toString()) : it.value | ||
+ | ] | ||
+ | } | ||
+ | formField.setFieldOptions(optionsMap) | ||
+ | } else if (getActionName() == " | ||
+ | def optionsMap = noneMap + options.findAll { | ||
+ | it.value in [" | ||
+ | }.collectEntries { | ||
+ | [ | ||
+ | (it.optionId.toString()) : it.value | ||
+ | ] | ||
+ | } | ||
+ | formField.setFieldOptions(optionsMap) | ||
+ | } else { | ||
+ | def optionsMap = noneMap + options.findAll { | ||
+ | it.value in [" | ||
+ | }.collectEntries { | ||
+ | [ | ||
+ | (it.optionId.toString()) : it.value | ||
+ | ] | ||
+ | } | ||
+ | formField.setFieldOptions(optionsMap) | ||
+ | } | ||
+ | |||
+ | </ | ||
+ | References: | ||
+ | [[https:// | ||
+ | [[https:// | ||