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

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

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

Annyone with better ideas?

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 ..

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:

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

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")))

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.

Lunchtime, shall check it in an hour. :)

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

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

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.

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.

-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

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