Forums

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

Dont know why i am getting this error groovy.lang.MissingPropertyException: No such property: issue

maharshi kondapaneni June 10, 2019

groovy.lang.MissingPropertyException: No such property: issue for class: Script84 at Script84.run(Script84.groovy:20)

this error shows when i am trying to execute the following code :

i

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue

import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.fields.CustomField

import org.apache.log4j.Logger
import org.apache.log4j.Level

import java.util.*
import java.lang.*

def log = Logger.getLogger("logger")
log.setLevel(Level.INFO)

def customFieldManager = ComponentAccessor.getCustomFieldManager()

CustomField codeChangeObject = customFieldManager.getCustomFieldObjectByName('Code Change Information')
assert codeChangeObject != null
String codeChangeValue = issue.getCustomFieldValue(codeChangeObject)
CustomField reasonFieldObject = customFieldManager.getCustomFieldObjectByName('Reason code was not merged to Master')
assert reasonFieldObject != null
String reasonChangeValue = issue.getCustomFieldValue(reasonFieldObject)

if (issue.getProjectObject().getKey() == 'EP')
{
log.info("Project key was EP.")
return true
}

else if (codeChangeValue =~ /.*(\bmaster OPEN\b).*/)
{
if (reasonChangeValue.equals(null))
{
log.info("'Reason code was not merged to Master' field not populated.")
return false
}

else if (!reasonChangeValue.equals(null))
{
log.info("'Reason code was not merged to Master' field populated.")
return true
}
}

else
{
log.info("Else case executed.")
return true
}

 

1 answer

1 accepted

0 votes
Answer accepted
Ismael Jimoh
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.
June 10, 2019

Hi @maharshi kondapaneni ,

May I ask:

  1. Where are you using this script? Event listener, workflow, Script field?
  2. I do not see you defining/initialising issue anywhere?

It would be tough but this is just an initial look at your code and it would be great to know where the script is being triggered from.

maharshi kondapaneni June 17, 2019

Hello @Ismael Jimoh  it is being run in the script runner 

Ismael Jimoh
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.
June 18, 2019

Hi @maharshi kondapaneni 

Scriptrunner is an add-on that triggers scripts to perform certain operations.

However what triggers the script depends on where you placed the script hence why I asked, Where are you using the script.

Did you place your script in:

  • the workflow(e.g. Condition or post-function)?
  • The Script Listener
  • Are you running it from the script console?
  • Others?

I would need to know this because depending on where you are triggering your script from, you may need to define the issue differently.

See the reply here as the problem is the same as what you are facing. Depending on where you are running the script, you need to define issue only then can you use:

if (issue.getProjectObject().getKey() == 'EP')

Which is where I believe you code is failing.

It does not understand what issue is.

Cheers.

Kristján Geir Mathiesen
Community Champion
July 28, 2021

I know this is an old thread but just wanted to let you @Ismael Jimoh know that your answer helped me with another problem :)  Thank you very much!

KGM

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events