Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

the Variable [issue] is undeclared

Jon Kocen
Contributor
October 31, 2019 edited

Getting an error : the variable [issue] is undeclared

I am using this in a Post Function of a workflow

Server 8.3.2 with ScriptRunner 5.6.6.1-jira8

import com.atlassian.jira.component.pico.ComponentManager
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.MutableIssue;
import com.atlassian.jira.bc.issue.IssueService;
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.issue.IssueManager;

def projectName = issue.project.name;

3 answers

2 accepted

Suggest an answer

Log in or Sign up to answer
0 votes
Answer accepted
Antoine Berry
Community Champion
November 6, 2019

I believe that the console is just a java interpreter and is not "aware" that the issue object will be defined at execution time. That is why it is showing a warning that it is not declared. Also your code is fine, it works in groovy (which is meant to have more simple syntax).

Jon Kocen
Contributor
November 6, 2019

Thanks for the explanation of the console.

0 votes
Answer accepted
Juan Ramón Alonso
Community Champion
October 31, 2019

It would be better something like issue.getProjectObject().getName() but your code should work. I don't see an error, and I have just put your code in a postfunction and it works. Nevertheless I have experienced some kind of hangs with scriptrunner script console from time to time, so I would try to log out and log back in, closing the browser and even clearing the browser's cache. 

Srikanth Ganipisetty
Contributor
November 21, 2021

String org1_val = issue.getCustomFieldValue(cf_org1) I have the same error but was unable to solve the issue. any leads @Juan Ramón Alonso @Jon Kocen 

0 votes
Michael Kornatzki
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 31, 2023

it would be nice if the scriptrunner editor know's the standard injected variables.

Then the script colud show as valid

TAGS
atlassian, confluence, loom, atlassian intelligence, ai notes, ai-powered meeting notes, atlassian community events, ace, confluence ai, loom ai integration, ai note-taking, atlassian ai features, team '25, atlassian live learning, confluence automation

Unlock AI-powered meeting notes: Join our live learning session! 📹

Did you catch the news at Team ‘25? With Loom, Confluence, Atlassian Intelligence, & even Jira 👀, you won’t have to worry about taking meeting notes again… unless you want to. Join us to explore the beta & discover a new way to boost meeting productivity.

Register today!
AUG Leaders

Atlassian Community Events