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

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 Oct 31, 2018 in Marketplace Apps

Marketplace Spotlight: Zephyr

Hello Atlassian Community! Each month, we run a series of Spotlights to highlight Marketplace vendors and apps that our team thinks this Community would find valuable. In last month's Spotlig...

320 views 0 1
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