Hi,
I have a listener script on my Jira cloud, this is the first part of it:
def sourceIssueResponse = get("/rest/api/2/issue/issuekey?fields=project,issuetype").asObject(Map)
def sourceIssueKey = ''
def sourceIssueType = ''
logger.info("sourceIssueResponse" + sourceIssueResponse.body)
if(sourceIssueResponse && sourceIssueResponse.body){
sourceIssueKey = sourceIssueResponse.body.key
sourceIssueType = sourceIssueResponse.body.fields.issuetype.name
}
(issuekey is where the issue key is going)
I get an error notification on the line "sourceIssueType = sourceIssueResponse.body.fields.issuetype.name", but the script is working fine (its not related to the rest of the script).
I also have a warning on this line: "no such property issuetype for class object".
Does anyone know how to solve this? I searched on the community and online and didn't find anything.
Thank you!
Hey @Aviv Eldad , welcome to the Atlassian Community!
From ScriptRunner listener or post function you can access the issue directly without a request to Jira. You can try accessing the issuetype with the code below:
'''sourceIssueType = issue.fields.issuetype.name'''
You might also want to log some of those variables to see what you get from the body. Try using logger.info() to log any of the above variables.
Let me know if this helps!
I tried and I get a warning "The variable [issue] is undeclared". Do I need to call it with event like Jira server?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.