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.
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
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)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
It is part of the free Workflow Building Blocks for Jira app.
I hope it will help.
Cheers
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Radia Bouraib are you using Scriptrunner?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You can do that within the workflow of your issue type, without the use of an app like the following image:
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.