Script Workflow Validator Help

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

        default :
            res = false
return res

3 answers

Hey Phil,

Try changing

if (cf.getValue(issue).toString() == 'Supplier1')


if (cf.getValue(issue).toString().equals('Supplier1'))



Hi Bhushan,

Unfortunately this has not worked. I believe the problem is that the Issue has not yet been created in the database on the Create Validator

You're correct, validation comes before the postfunction and there the first step is 'Create the issue originally', so the issue hasn't been created at that stage.

How can you access/set the pre saved Issues values?

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Julia Dillon
Posted Tuesday in Jira

Tell us how your team runs on Jira!

Hey Atlassian Community! Today we are launching a bunch of customer stories about the amazing work teams, like Dropbox and Twilio, are doing with Jira. You can check out the stories here. The thi...

682 views 1 18
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you