I have written the following script to run on the Create workflow transition and it always retrurns False. I have tested it using the Script Console manually retrieving an issue and it works. Are you able to help with this??
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.Issue
ComponentManager componentManager = ComponentManager.getInstance()
//issue = componentManager.getIssueManager().getIssueObject("PROP-1310")
pcm = componentManager.getProjectComponentManager()
pc = pcm.findComponentsByIssue(issue)
CustomFieldManager customFieldManager = componentManager.getCustomFieldManager()
CustomField cf= customFieldManager.getCustomFieldObject("customfield_12114")
boolean res
res = false
for (c in pc) {
switch (c.getName()) {
case ['test', 'test2']:
if (cf.getValue(issue).toString() == 'Supplier1') {
res = true
} else {
res = false
}
break
default :
res = false
}
}
return res