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
}
May I ask:
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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:
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.