Groovy Script Runner: conditions

GilK
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 17, 2012

Hi,

The Fix Version is a mandatory field for bugs.

However, when the resolution is not fixed (i.e. duplicate), there is no need for the Fix Version field.

I'm trying to get it work via Script Runner:

issue.resolution?.name != 'Fixed' || issue.fixversion is not empty

What is wrong?

Thanks,

Janiv.

1 answer

1 accepted

2 votes
Answer accepted
JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 17, 2012

I'm not really sure what you're trying to do, but you're mixing up groovy with what looks like JQL.

issue.resolution?.name != 'Fixed' || issue.fixVersions

will be true if the resolution is Fixed, or the fix version is not empty... however you can't unrequire a field that is required in the field config scheme.


GilK
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 17, 2012

Hey,

I want the FixVersion to be mandatory only if the resolution is Fixed.

Using the groovy I succeeded to unrequire a field that is required in the field config scheme.

If I use the following script: issue.resolution?.name != 'Fixed'

and remove theJIRA default mandatory field Condition

and I don't set the Fixed Version, it works !

All I have to do now, make sure that Fixed resolution must be set together with Fixed version one.

Can you help me pleasE?

Thanks,

JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 17, 2012

Which built-in script are you using? And is it a condition, validator, or post-function?

GilK
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 18, 2012

It is a validator and I use the Groovy script (Script Validator -Runs a script to check validation).

Thanks,

JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 18, 2012

I'm totally confused. With many of the builtin scripts you can provide a condition which is in the form of a mini groovy script that returns true or not true. Are you using the one called Simple Scripted Validator? A screenshot would help here.

I think my original answer is correct. Try it in the Admin -> Built-in scripts -> Condition Tester.

GilK
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 18, 2012

Using the tester:

issue.resolution?.name != 'Fixed' || issue.fixversion is not empty

returns:

org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: Script28.groovy: 1: expecting EOF, found 'is' @ line 1, column 55. = 'Fixed' || issue.fixversion is not emp ^ 1 error

Using the tester:

(issue.resolution?.name != 'Fixed') || (issue.fixversion?.name != '')

returns:

javax.script.ScriptException: groovy.lang.MissingPropertyException: No such property: fixversion for class: com.atlassian.jira.issue.IssueImpl Possible solutions: fixVersions

Thanks,

JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 18, 2012

Did you see what I put in my answer? It was:

issue.resolution?.name != 'Fixed' || issue.fixVersions

GilK
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 18, 2012

I just noticed it ...

Thanks, it works great !

Suggest an answer

Log in or Sign up to answer