Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,554,066
Community Members
 
Community Events
184
Community Groups

the Variable [issue] is undeclared

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;

2 answers

2 accepted

0 votes
Answer accepted
Antoine Berry
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Nov 06, 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).

Thanks for the explanation of the console.

0 votes
Answer accepted
Juan Ramón Alonso
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Oct 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. 

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 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events