It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Groovy simple script validator radio button

Sir Be Jul 22, 2014

I have a script that works in Jira 4.2 and groovy version 1.7.13

!(cfValues['Requested start date']!=cfValues['Requested end date']&&!(cfValues['Requested daytime'].equals("Whole day")))

Requested start and end date are date pickers (no time), requested daytime is a radio button field with options morning, afternoon and whole day.

Now i want to have the same script, but in groovy version 1.7.3-1 (and jira 4.2)

The exact same script doesn't work.

when i do

println cfValues['Requested daytime']?.value

println cfValues['Requested daytime']?.getValue()

it both gives me 'null'

println cfValues[10053] (req dt's id) also gives null

Does the 1.7.3-1 version know how to take care of radio button fields?

Upgrading to 1.7.13 (or higher) is not an option (unless there's no other choice)

3 answers

1 accepted

0 votes
Answer accepted
Sir Be Jul 28, 2014

The rule didn't work so didn't used it.

Annyone with better ideas?

0 votes
Sir Be Jul 22, 2014

println cfValues[10053][0] gives javax.script.ScriptException: java.lang.NullPointerException: Cannot invoke method getAt() on null object

My req dt is on the screen and is filled in ..

0 votes
JamieA Jul 22, 2014

This is correct:

cfValues['Requested daytime'].value

if it's a select list or radio buttons etc.

The return type of "println" is void, which is why it would show null. If you open the catalina.out file you would see the output there.

Try using an assertion in the condition tester: https://jamieechlin.atlassian.net/wiki/display/GRV/Built-In+Scripts#Built-InScripts-PowerAssertions

Sir Be Jul 22, 2014

I don't know why, but assert doens't seem to show anything ...

(or certainly not like it's in your example)

It only gives me an error

Trying it out with the .value, keeping you informed

Sir Be Jul 22, 2014

Where is catalina.out default located?

Not in the C:\Program Files (x86)\Atlassian\JIRA 4.2.4-b591\logs folder

catalina.log does exist, nothing special in there

error doesn't appear when it should

My function:

!(cfValues['Requested start date']!=cfValues['Requested end date']&&!(cfValues['Requested daytime'].value.equals("Whole day")))

JamieA Jul 22, 2014

It's platform dependent but that's not my point, my point was not to use println and expect to see the result on the screen.

>> My function

Do it one clause at the time, in the condition tester.

Sir Be Jul 22, 2014

Lunchtime, shall check it in an hour. :)

Sir Be Jul 22, 2014

Tested it on a wrong (should be non-existing) issue

start and end date on different day and requested daytime is morning

!(cfValues['Requested start date']!=cfValues['Requested end date']&&!(cfValues['Requested daytime'].value.equals("Whole day"))) -> false

!(cfValues['Requested daytime'].value.equals("Whole day")) -> true

cfValues['Requested start date']!=cfValues['Requested end date'] -> true

So theoritically, the issue shouldn't exist cause the validator rule is good

However the rule doens't work

An issue with different dates and daytime not to whole day, gets created

Sir Be Jul 22, 2014

However if I check with the conditioner on a good issue

2 different dates and whole day

cfValues['Requested daytime']=="Whole day" -> true

cfValues['Requested daytime'].value=="Whole day" -> false

JamieA Jul 22, 2014

You wouldn't get Atlassian support for this version of jira, and personally I'm not inclined to either, it;s just too old, and too much has changed.

JamieA Jul 22, 2014

You should use:

cfValues['Requested daytime']?.value= ...

unless you know this field will ALWAYS be filled in.

I don't understand the difference between a good and bad issue.

I think on such an old version of jira you just don't want .value. You will need to change that when you upgrade to 4.4.

Sir Be Jul 22, 2014

-These fields are all required.

-bad issue=requested start date different from requested end date and requested daytime is morning or afternoon

good issue= all other possibilities

So it may not be possible to create an issue with an afternoon/morning spread over multiple days

-One day we will upgrade to a newer version ..., but it's not this day.

Until that day, how can I make it work ??

-Great now I'm getting always error messages :(

This should work according to the condition tester , but when i put it in a validator rule in my workflow, it doesn't work...
(!((cfValues['Requested start date']!=cfValues['Requested end date'])&&!(cfValues['Requested daytime'].equals("Whole day"))))

Suggest an answer

Log in or Sign up to answer
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Published in Jira

Try Jira Cloud for Outlook: Organize your work without leaving your inbox

Hi Atlassian community, My name is Max and I work on the product integration team at Atlassian. I am pleased to announce the early access program for the Jira Cloud add-in for Outlook. This add-in...

2,019 views 6 15
Read article

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you