Hi,
I have a target release field and would want to add value to it based on an issue creation. This field is not being used in the current issue that is being created but in another project. Any pointers?
example -
Project A with Issue Type Release. On creation of Release in Project A, the summary should get added to the Target Release (Project Specific Select List) so it can be used in Project B with Issue Type Target Release.
Any pointers would be appreciated?
Thanks,
Hi @aditya442
String optionName = XXXXCustomField customField = ComponentAccessor.getCustomFieldManager().getCustomFieldObject('customfield_xxxxxx')Project project = ComponentAccessor.getProjectManager().getProjectByCurrentKey('XXXX')OptionsManager optionManager = ComponentAccessor.getOptionsManager()FieldConfigScheme fieldContexts = getFieldContext(customField, project)FieldConfig fieldContxt = fieldContexts.getConfigs().get(fieldContexts.getConfigs().keySet().first())if(fieldContxt){if(!optionManager.getOptions(fieldContxt).getOptionForValue(optionName, null)){optionManager.createOption(fieldContxt, null, null, optionName)}}
I did not test the script but the section that add the option is the one I use in my scripts
Regards
What is the error message ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi
I just tested the script and fixed the issue
import com.atlassian.jira.issue.fields.config.FieldConfigimport com.atlassian.jira.issue.fields.config.FieldConfigSchemeimport com.atlassian.jira.issue.customfields.manager.OptionsManagerimport com.atlassian.jira.project.Projectimport com.atlassian.jira.issue.fields.CustomFieldimport com.atlassian.jira.component.ComponentAccessor
String optionName = "XXXXX"CustomField customField = ComponentAccessor.getCustomFieldManager().getCustomFieldObject('customfield_XXXXX')Project project = ComponentAccessor.getProjectManager().getProjectByCurrentKey('XXX')OptionsManager optionManager = ComponentAccessor.getOptionsManager()FieldConfigScheme fieldContexts = ComponentAccessor.getFieldConfigSchemeManager().getRelevantConfigScheme(project, customField)if(fieldContexts){FieldConfig fieldContxt = fieldContexts.getConfigs().get(fieldContexts.getConfigs().keySet().first())if(fieldContxt){if(!optionManager.getOptions(fieldContxt).getOptionForValue(optionName, null)){optionManager.createOption(fieldContxt, null, null, optionName)}}}
Regards
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.