.groovy file on the workflow condition not working

S. Ravi Venkatramana August 5, 2014

Hi,

There is one strange behaviour I am observing in the workflow conditions.

I have a workflow button called 'Modify', I would like to show this button only in certain conditions.

I have written a groovy file which return either true or false. If the return value is true the button will be visible where as if it is false the button will be hidden from the user.

Now the problem here is, if I put this code directly in the simple scripted condition, everything works perfectly. Where as if I put this code in a file and refer that file path in a script condition this code is not working, the button is visible even if the groovy file returns false.

I checked that the groovy script is running in both the cases though.

Is it a bug or expected behaviour. Since the script is quite long, I would prefet it to be kept in a file and referenced rather than directly putting it on the screen.

Steps to Reproduce this:

1. Take one simple workflow, with a transition called Modify

2. Add a condition --> Script Condition --> Simple Scripted Condition-->return false

The Modify button will be hidden

3. put return false in a groovy file, refer it in the conditon

Add a condition --> Script Condition -->Give file path in Script File Path

The Modify button will be still visible when you run the code

JIRA Version - 6.0.6

Script Runner Version - 2.1.11

Kindly suggest.

1 answer

1 accepted

1 vote
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.
August 6, 2014

I think you're comparing "Simple scripted condition" with writing a custom condition (understably confusing).

For a file you should use:

passesCondition = false

Docs: https://jamieechlin.atlassian.net/wiki/display/GRV/Conditions

Simple scripted condition just aimed to make simple one-liners easier. Hopefully it's clearer in 3.0, where everything can be either inline or in a file.

S. Ravi Venkatramana August 6, 2014

Hi Jamie,

I updated the groovy runner plugin to the latest version and used "Custom Condition" to refer the file.

It started working as expected.

Thank you for quick support

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events