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

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


1 badge earned


Participate in fun challenges

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


Gift kudos to your peers

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


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!


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
Community Members
Community Events
Community Groups

Variable "issue" masks a binding of the same name. Please choose a different name for the variable.

I'm getting this warning (see screenshot) even though my script works perfectly fine.  

variable issue is undelcared.png


I've read through the forums as many people have posted this error but no answers seem to make any sense.  Anyone have any practical advice to fix this error for scripts stored like this one?


I'm guessing I have some kind of syntactical error but trying to modify my script to look like others here isn't working.


This script is used for a script field.


2 answers

1 accepted

0 votes
Answer accepted

I think this is somewhat expected.

This script doesn't exist in a vacuum. If you tried to run in the console it would not work because it assumes a certain binding for the context that it will be run in to exist.

For example, if this is a post-function script, when you go to the configuration where that file is called, the static type checking should report green (no errors) because in that context, the issue variable will be declared and the static type checking known that. 
In the Script Editor, the static type checking doesn't know where you intend to use that script and what bindings will be available.

Adding Issue issue= issue in a script is really just a hack/trick to hide ALL OTHER static type checking you would otherwise see in the script editor.

You have to accept this error and move on. Any workaround to get rid of the errors will bring more headache or code complexity than they're worth.
For the record, this should work (I've never actually tried to use this in prod):

//You want to use a different variable than 'issue', otherwise you may get an error that 'issue is already declared'
//and obviously, all subsequent calles to issue should be replaced with new variable name
Issue myIssue = this.binding.variables['issue']

You can read more about Static Type checking here:

My recommendation is to ignore the error. If that's the only one you see in your script, it's in better shape than the majority of my scripts in my environment (>180 scripts).

You see that errors in the Script editor ... but I suspect if you were to put the exact same code n the Script Field in-line script box, you would see this different error instead:

2021-07-21 15_08_17-Window.png

To avoid that error in in-line script, you could remove the line altogether or set it to this:

2021-07-21 15_12_42-Window.png

But this would show the same error in the script editor since script editor doesn't know about "issue".

In the script, "this" can be used to access the class that contains the script, and one of the built-in properties of a script class is its binding which contains the variables defined prior to calling the script.

There is not a single line that you can replace your line 14 that will just work any of the lines I suggest will result in either an error in the Script File Config (context-aware) or in the Script Editor (not context-aware).

The only solution is to NOT attempt to re-use the existing "issue" variable and instead declare a new variable with a different name and loading it with the "this.binding.variables['issue']"

Yes thank you Peter.  It's the only warning and the script runs fine so I've learned to live with it.   It's interesting to learn how the STC works different in the editor versus console versus in-line script.  Thanks for the thorough explanation.

You're welcome.

Might I suggest you change the accepted answer to the answer I provided instead of your reply that was posted as a new response?

Good catch, answer accepted changed. :)

Thank you for the response Peter.  I think I'm following what you are saying.


To try your code out in our UAT environment would I literally write this?

Issue myIssue = this.binding.variables['issue']

 aka I  would replace my line with the above line as is?

I'm not sure what you mean 'this.binding.variables['issue'] part.  I don't understand if I'm supposed to put something else there other than what you literally wrote.

Perhaps easier said is, if you were to look at my screenshot and were to replace line 14. how exactly would you replace that line?

Ideally something I could copy and paste exactly.


The code is for a script field which has its context set for various issue types and different projects.

Suggest an answer

Log in or Sign up to answer

Atlassian Community Events