Script Runner Validation, I need to make sure the value of a select list custom field is not none before an issue is posted, it can be any other value. Here is some of the code I have tried in Script Runner Console. Am I going about this the right way? I'm using the Script Runner Examples.
import com.opensymphony.workflow.InvalidInputException
import org.apache.log4j.Category
log = Category.getInstance("com.onresolve.jira.groovy.OneOrOther")
log.debug("In Validator groovy script")
if (cfValues['Defect Source'] == false) {
invalidInputException = new InvalidInputException("Cannot have Defect Source equal to none!")
}
import org.apache.log4j.Category
import com.opensymphony.workflow.InvalidInputException
log = Category.getInstance("com.onresolve.jira.groovy.example.testValidator")
log.debug("Condition testValidator script running")
if (cfValues['Defect Source'] == false) {
invalidInputException = new InvalidInputException("Cannot have Defect Source equal to none!")
}
import com.opensymphony.workflow.InvalidInputException
CustomFieldManager customFieldManager = componentManager.getCustomFieldManager()
String sourceCfId = "Defect Source"
String targetCfId = "Defect Source"
CustomField cfSource = customFieldManager.getCustomFieldObject(sourceCfId)
CustomField cfTarget = customFieldManager.getCustomFieldObject(targetCfId)
if (issue.getCustomFieldValue(cfSource) == false) {
invalidInputException = new InvalidInputException("Cannot have Defect Source equal to none!")
}
Block 1 error: javax.script.ScriptException: groovy.lang.MissingPropertyException: No such property: cfValues for class: Script21
Block 2 error: javax.script.ScriptException: groovy.lang.MissingPropertyException: No such property: cfValues for class: Script10
Block 3 error: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: Script22.groovy: 3: unable to resolve class CustomFieldManager @ line 3, column 20. CustomFieldManager customFieldManager = componentManager.getCustomFieldManager() ^ Script22.groovy: 6: unable to resolve class CustomField @ line 6, column 13. CustomField cfSource = customFieldManager.getCustomFieldObject(sourceCfId) ^ Script22.groovy: 7: unable to resolve class CustomField @ line 7, column 13. CustomField cfTarget = customFieldManager.getCustomFieldObject(targetCfId) ^ 3 errors