Hello everyone, I would like to know how I can retrieve an issue on Jira from his ID, knowing that with this code I have the following error:
No signature of method: org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.getIssueByID() is applicable for argument types: (java.lang.Long) values: [92197]
"Cannot find matching method" in my script
I’ve tried a lot of other methods, but always the same mistake.
import com.atlassian.jira.issue.Issue
long issueId = 92197
Issue issue = getIssueByID(issueId)
return issue
Hi @baptistemuller ,
Kindly try :
import com.atlassian.jira.component.ComponentAccessor
def issueManager = ComponentAccessor.getIssueManager()
long issueId = 92197
def issue = issueManager.getIssueObject(issueId)
return issue
Antoine
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Glad to help ! If you are satisfied with the answer you may consider marking it as accepted. :)
Antoine
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello again @Antoine Berry ,
can you tell me why my condition don't pass please ?
Sry to have bothered you.
PS: customFieldValue does have the value "Improvement"
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.*
import org.apache.log4j.Level
log.setLevel(Level.DEBUG)
//Issue and CustomField Manager
IssueManager issueManager = ComponentAccessor.getIssueManager()
CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager()
//Issue's Id
long issueId = 92197
//the current issue
Issue issue = issueManager.getIssueObject(issueId)
//CustomField Name
def customField = customFieldManager.getCustomFieldObjectByName("Pre-Qualification")
//Value of the CustomField of the current issue
Object customFieldValue = customField.getValue(issue)
log.debug(customFieldValue)
if(customFieldValue == "Improvement"){
return "customFieldValue == Improvement"
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hard to tell not having access to the issue details, logging is your best friend here. I suspect your Pre-Qualification field is a select list, so you would have to use the method getValue() since you initially get a LazyLoadedOption object.
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.*
import org.apache.log4j.Level
log.setLevel(Level.DEBUG)
//Issue and CustomField Manager
IssueManager issueManager = ComponentAccessor.getIssueManager()
CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager()
//Issue's Id
long issueId = 92197
//the current issue
Issue issue = issueManager.getIssueObject(issueId)
//CustomField Name
def customField = customFieldManager.getCustomFieldObjectByName("Pre-Qualification")
//Value of the CustomField of the current issue
Object customFieldValue = customField.getValue(issue)
log.debug("customFieldValue : " + customFieldValue)
log.debug("customFieldValue class : " + customFieldValue.getClass())
if(customFieldValue.getValue() == "Improvement"){
return "customFieldValue == Improvement"
}
Antoine
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Result:
customFieldValue == Improvement
Logs(2):
2019-04-29 15:24:06,075 DEBUG [runner.ScriptRunnerImpl]: customFieldValue : Improvement 2019-04-29 15:24:06,076 DEBUG [runner.ScriptRunnerImpl]: customFieldValue class : class com.atlassian.jira.issue.customfields.option.LazyLoadedOption
it works, thank you a lot!!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Can you please share how can I find the issue ID number?
Thanks,
Maya
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Maya Hocherman ,
If you cannot find the answer on this topic, I would suggest you open a new question so we are able to grasp your problem and answer it as precisely as we can.
Antoine
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.