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

This widget could not be displayed.

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
Community showcase
Published Aug 22, 2018 in Marketplace Apps

How a Marketplace app tech team is achieving gender diversity

Hello! My name is Genevieve Blanch, and I'm the Marketing Manager at RefinedWiki, creators of apps to give teams the tools to customize Atlassian platforms. Currently, 44% of the tech team at Re...

492 views 3 18
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