No signature of method Error

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

 

1 answer

0 vote

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

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Bridget Sauer
Published Thursday in Marketplace Apps

Calling all developers––You're invited to Atlas Camp 2018

 Atlas Camp   is our developer event which will take place in Barcelona, Spain  from the 6th -7th of   September . This is a great opportunity to meet other developers and get n...

80 views 0 5
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you