compare a date custom fields validator using jira expression

Radia Bouraib September 7, 2021

Hi!

I'm working on a project where I have a screen with custom date fields, I would like to use a validator using the jira expression to compare this field to the calendar date.
I tried with this code:
issue.customfield_10057.toCalendarDate() <= new CalendarDate().plusMonths(3).
but it doesn't work
can you help me with this. 

3 answers

1 vote
Oliver Siebenmarck _Polymetis Apps_
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.
September 7, 2021

Hi @Radia Bouraib ,

I believe you want something like this:

new Date(issue.customfield_10057) <= new Date().plusMonths(3)

You'll need to create a date object from your customfield with new Date() before you can compare it.

The documentation for Jira Expressions is pretty nice, but in my mind nothing beats trying things out yourself. We have a free app called Expression Tester to do just that, give it a try if you like.

Best regards,
 Oliver

sekhar reddy
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.
December 13, 2022

Hi @Oliver Siebenmarck _Polymetis Apps_ 

Thank you very much for this expression, my requirement is different but this is helped to resolve my issues. I am comparing two Date & Time fields, Actual End should be less than or equal to Planned End date. I have used below expression and it worked.


new Date(issue.customfield_10009) <= new Date(issue.customfield_10145)

Like # people like this
0 votes
Maciej Dudziak _Forgappify_
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.
April 18, 2024

Hi,

I am from Forgappify team. To make dates comparison easier, we developed wizzard-like Dates Compare Validator / Condition.

You can compare two date fields, including both date and date & time fields. You have the option to choose whether to include the time part in the comparison, and the fields are automatically converted to the required format. You can also set an offset for both the field and the current timestamp.

Below the wizard, you'll find the Jira expression preview, generated for your convenience, providing clarity on the exact actions performed by the validator/condition. 

community_19.04_dates_compare.png

It is part of the free Workflow Building Blocks for Jira app.

I hope it will help.

Cheers

 

 

0 votes
Alex Koxaras _Relational_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 7, 2021

Hi @Radia Bouraib are you using Scriptrunner?

Radia Bouraib September 7, 2021

@Alex Koxaras _Relational_  i use Power script. 

Alex Koxaras _Relational_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 7, 2021

You can do that within the workflow of your issue type, without the use of an app like the following image:

date compare.png

If you want to use powerscipt to do that real-time, like a behavior short-of-thing, then I would suggest that you should refer to the documentation of powerscript. Unfortunately I haven't use this app.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events