Hello folks!
I trying to update drop down select custom field in Jira 7.6 and got the error. What is wrong here?
:
def cfm = ComponentAccessor.getCustomFieldManager()
def im = ComponentAccessor.getIssueManager()
MutableIssue issue = im.getIssueObject("OPS-11250")
def portfolioCF = cfm.getCustomFieldObjectsByName("Portfolio")
def portfolioCFget = issue.getCustomFieldValue(portfolioCF)
def portfolioConf = portfolioCF.getRelevantConfig(ussue)
def portfolioCfopt = ComponentAccessor.optionsManager.getOptions(portfolioConf)
log.error("Portfolio options - " + portfolioCfopt)
def value = portfolioCfopt?.find
{
it.toString() == "Some value"
}
log.error("Setting value " + value)
issue.setCustomFieldValue(portfolioCF, value)
No signature of method: com.google.common.collect.SingletonImmutableList.getRelevantConfig() is applicable for argument types: (com.atlassian.jira.issue.IssueImpl) values: [OPS-11250]
groovy.lang.MissingMethodException: No signature of method: com.google.common.collect.SingletonImmutableList.getRelevantConfig() is applicable for argument types: (com.atlassian.jira.issue.IssueImpl) values: [OPS-11250] at set_application.run(set_application.groovy:48)
Use this:
def cf = customFieldManager.getCustomFieldObjectByName('Some Custom Field Name')
def cfConfig = cf.getRelevantConfig(issue)
def customFieldOptions = ComponentAccessor.optionsManager.getOptions(cfConfig)
def changeHolder = new DefaultIssueChangeHolder();
def fieldOption = customFieldOptions.find {it.value == "Some Value"}
cf.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(cf),fieldOption),changeHolder);
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I think that the problem relies in getCustomFieldObjectsByName() is returning a collection of custom fields, even if it has just one element:
So, portfolioCF is actually a collection of custom fields, and not merely the custom field you wish. May you try changing its definition to:
def portfolioCF = cfm.getCustomFieldObjectsByName("Portfolio")[0]
This way, the first element (custom field, in this case) will be returned and assigned to portfolioCF.
Assuming there's just one custom field named Portfolio, I think you'll get what you need.
Also beware of the typo in the word 'issue' here:
getRelevantConfig(ussue)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
After adding "[0]" error disappeared, but the field was not updated.
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.