It's not the same without you
Join the community to find out what other Atlassian users are discussing, debating and creating.
When building a script through the script console, I am receiving this error:
Error!
No signature of method: com.atlassian.jira.issue.DocumentIssueImpl.setCustomFieldValue() is applicable for argument types: (com.atlassian.jira.issue.fields.CustomFieldImpl, java.lang.String) values: [CustomerRank, Silver] Possible solutions: getCustomFieldValue(com.atlassian.jira.issue.fields.CustomField)
My script is as follows:
import com.atlassian.jira.bc.issue.search.SearchService
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.jql.parser.JqlQueryParser
import com.atlassian.jira.web.bean.PagerFilter
import org.apache.log4j.Logger
import com.atlassian.jira.issue.MutableIssue
def log = Logger.getLogger("com.onresolve.jira.groovy.MyScript")
def jqlQueryParser = ComponentAccessor.getComponent(JqlQueryParser.class)
def query = jqlQueryParser.parseQuery(""""Customer Account" in accountsByCategory(silver) and createdDate > startOfMonth()""") // query as you would enter in to issue nav
def searchService = ComponentAccessor.getComponent(SearchService.class)
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def results = searchService.search(user, query, PagerFilter.getUnlimitedFilter())
def issueManager = ComponentAccessor.getIssueManager()
def commentManager = ComponentAccessor.getCommentManager()
def customFieldManager = ComponentAccessor.getCustomFieldManager()
results.getIssues().each {issue ->
def cf = customFieldManager.getCustomFieldObjects(issue).find {it.name == 'CustomerRank'}
issue.setCustomFieldValue(cf, 'Silver')
}
Can you please help me identify what I am doing wrong?
Thank you,
KCP
When you search the result that you get is a DocumentIssue... which corresponds to a Lucene document representing the issues fields. To update a CF value you get to get hold of a mutable issue.
This example shows how: https://jamieechlin.atlassian.net/wiki/display/GRV/Miscellaneous+Groovy+Scripts#MiscellaneousGroovyScripts-ExecutingaQuery
It started as any story starts, on a normal, rainy day. Admin meets App, and her name was Klok2, and like any first relationship we were both trying to make it work but neither one knew what...
Connect with like-minded Atlassian users at free events near you!
Find a groupConnect with like-minded Atlassian users at free events near you!
Unfortunately there are no AUG chapters near you at the moment.
Start an AUGYou're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.