Using JWT Jira Expression validator, how can I compare the issue created date to a specific date.

McCluskey_ James February 28, 2024

I'm trying to use a JWT expression validator to check that the issue is created on or after March 1st, 2024. 

 

When entering the text ..... issue?.created.toCalendarDate() >= "2024-03-04"

I get the error.... Jira expression evaluation failed: ["Evaluation failed: \"issue?.created.toCalendarDate() > \"2024-03-04\"\" - operator \">\" is not applicable to types: CalendarDate and String"]

 

This is frustrating as the documentation lists regular operators, such as >=, as valid operators for Date and Calendar Date data types so I'm not sure where I've gone wrong.

 

NOTE:  I understand I could simply use the date comparison validator to compare the dates, however I intend to add additional logic to my query which necessitates the JWT Expression Validator.

 

Any insight on how to correctly write this validation would be greatly appreciated.

 

1 answer

1 accepted

0 votes
Answer accepted
Thorsten Letschert _Decadis AG_
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
February 28, 2024

Hi @McCluskey_ James ,

While the operator is generally valid, the problem is that you're comparing different types - a CalendarDate with a String ("2024-03-04").

Are you actually planning to compare with a hard-coded timestamp, or are you going to use a relative expression, e.g.

issue?.created > new Date().minusMonths(1)

will return true if the issue has been created within the last month.

Edit:

For the hard-coded way, please try

issue?.created.toCalendarDate() >= new CalendarDate("2024-03-04")

Cheers,
Thorsten

McCluskey_ James February 29, 2024

Thank you much for explaining why it was failing as well as the expression!   Works like a charm.

Thorsten Letschert _Decadis AG_
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
February 29, 2024

Glad to hear! Just let me know if you need further help with adding the additional logic.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
PERMISSIONS LEVEL
Site Admin
TAGS
AUG Leaders

Atlassian Community Events