Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Cloud ScriptRunner Date Custom Field Validator

Zita Bagi
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 Champions.
January 27, 2021

 

I have a question about validating date customfield in Cloud.
this:
new Date(issue.customfield_10061).toISOString() > new Date().toISOString()
Still gives an error:
Evaluation failed: "new Date(issue.customfield_10061)" - The date has invalid format. Expected: ISO-8601, for example: 2011-12-03T10:15:30

I tried different versions:
//new Date(issue.customfield_10061).toCalendarDate("yyyy-MM-dd") > new Date().toCalendarDate("yyyy-MM-dd")
//(new Date(issue.customfield_10061).format("yyyy-MM-dd'T'HH:mm:ssZ")) > new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
//new Date(issue.customfield_10061).format("yyyy-MM-dd'T'HH:mm:ssZ", TimeZone.getTimeZone("UTC") > new Date().format("yyyy-MM-dd'T'HH:mm:ssZ", TimeZone.getTimeZone("UTC")

But I keep getting this same error message.
Can you please let me know how to parse a date custom field so taht it would be ISO-8601, if not with .toISOString()?

Thank you!

3 answers

1 vote
Christian Czaia _Decadis AG_
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 Champions.
May 26, 2013

How are your versions ordered? Maybe you could use fixVersion < XXX and fixVersion > YYY

0 votes
Ramiro P
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 Champions.
May 27, 2013

I think it is the same case as here:

https://jira.atlassian.com/browse/JRA-25901

This won't be easy but the only workaround I found is the one explained there, but you have to update the filter everytime a new version is created.

0 votes
richie_gee
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 26, 2013

Hi there,

I think you can achieve by a little help on advance searching:

project = TEST AND fixVersion = EMPTY AND updated &gt;= 2013-01-01 AND updated &lt;= 2013-03-31

Replace the project name, and the updated date presuming your quater is 1st Jan to 31 March.

Cheers :)

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events