how to set complex validators in jira's workflow ?

what i want is only user in "SWTL" project role can select except "Fixed" as resolution(like "Reject","Incomple"...), and all sw developers can select "Fixed" as resolution

so i add a script validator as below

isUserMemberOfRole('SWTL') && issue.resolution?.name != 'Fixed'

but the result is strange.

1 one user is of "SWTL" role ,and when choose Fixed,it prevents,but when choose not "Fixed" like "Reject" or "Incomplete" or others. it's ok.

2 if the user is not of "SWTL" role,no matter what resolution he choose,it prevents.

anyone can tell how to write the script condition in "Validators"

3 answers

1 accepted

1 vote

A validator can be thought of as a simple logical question. If the answer is yes, it passes, if the answer is no, it fails.

Your logic says "if the user is a member of the group SWTL and resolution is not fixed". If you think about that carefully, what you're saying is that the person MUST be a member of the group SWTL and the resolution must be something other than fixed. It's the first clause that's killing the other users because they're not in the group...

I think what you need is more like

If (user is member of the SWTL group and resolution != fixed) OR (user is NOT member of SWTL group)

thanks Nic,

i wrote the script:

isUserMemberOfRole('SWTL') || (! isUserMemberOfRole('SWTL') && issue.resolution?.name == 'Fixed')

and it works!

Nic do you know some examples about this kind of script,i want to know the syntax of this script.

because i even don't what type of this script,

I don't actually know. I have a strong suspicion that you have the script runner plugin installed, because on a standard Jira, you can't just whack in odd lines of code like that. See

Check that, and if it is what you're using, then the docs for it have loads of examples...

I suspect Nic is right because isUserMemberOfRole is a closure only defined in the script runner plugin afaik. The syntax is groovy, more or less a superset of java, which you can find tutorials for all over the web.

yes,i am using script runner.

anyone knows,or can provide some examples or syntax of the validate scripts in workflow?

Try Workflow PowerBox plugin and its validator templates. They allow to do grouped validators (like conditions). If you use "Run condition as validator" Validator and "Universal Issue Field Value Validator (including history)" you can reach your goal without scrpting

Here is link to documentation:

Suggest an answer

Log in or Join to answer
Community showcase
Maarten Cautreels
Posted yesterday in Off-topic

Friday Fun: What's your favourite beer/drink

As a Belgian, beer-lover and home brewer, beer is one of my great passions. I love the fact that with just a few ingredients (usually just water, hop and malt) you can create so many different tastes...

244 views 35 9
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
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot