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
Accepted answer

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 Sign up to answer
Community showcase
Published yesterday in Feedback & Announcements

How do you analyze GC logs, thread dumps and head dumps?

Hi awesome community!  In this article, I would like to describe the one of the toolset (service) for the analyze some problems on different Java-based instances, of course, as Atlassian admini...

95 views 0 7
Read article

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