You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
I have a question about validating date customfield in Cloud.
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()?
Hi Z B,
Thank you for your question.
I can confirm that the reason why you are getting the error is due to the fact that your code for the Workflow Validator is not valid code and I can confirm that Workflow Validators are defined using the Jira Expression Framework as documented in the Atlassian API documentation page located here or in the documentation page located here which explains how to add in a new validator to your workflow.
In your condition, you are writing Groovy Code which is not valid when defining Conditions or Validators inside of Jira Cloud and this is the reason why you are seeing the error which you are seeing.
We can confirm that when viewing the Jira Expression Framework API documentation page linked above you can navigate to the Context variables section which shows what variables are provided by this framework that can be used to create the expression.
If you then click on one of the variables it will show all the properties that can be called on the variable for the expression such as for the issue variable as shown here and you will be able to check this to see if Atlassian provides a variable that can be checked against to help create the validator which you require.
I am unable to provide an exact expression to achieve your requirement as our support process does not cover writing expressions or scripts, but you can use the resources shared above as a reference guide to help create that validator expression which you require.
I hope this information helps.
Thanks for letting me know that it was groovy and that you cannot actually help.
So I guess this is an expression:
issue.customfield_10061 > issue.created
But issue.customfield_10061 comes as a string, how can I parse it into a date?
When I try
also don't work, I get this error msg:
Evaluation failed: "issue.customfield_10061.toCalendarDate" - Unrecognized property of `issue.customfield_10061`: "toCalendarDate" ('toCalendarDate'). Available properties of type 'String' are: 'includes', 'indexOf', 'length', 'match', 'replace', 'slice', 'split', 'toLowerCase', 'toUpperCase', 'trim'
Please note that my response was designed to help yourself and I apologise if you feel I am not helping yourself.
I can confirm that if the field is a string then Atlassian will not allow this to be parsed to a date in the expression framework that they provide in Jira cloud as they only allow the methods which they document here to be called on string fields.
This, unfortunately, means that it is not possible to parse the value of the field to date as Atlassian does not allow this in Jira cloud as they do not provide any methods to do this and this caused by the differences in the API's between Jira Cloud and Jira Server.
Unfortunately, this means that it is not possible to achieve your requirement due to the reasons explained above.
My custom field is a date picker, but in the validator it says it's a string. Is this normal (referring to what you said about limitations) or am I just doing it wrong?
Also in the site you referenced I can see that I can get
and I'm not sure why I cannot call toISOString() here, if this is a date picker field. The error msg says I'm only allowed to call what'd available for prototype string. Is this the limitation you are mentioning or am I trying to get the value incorrectly?
I believe this a limitation of the expression framework if it is not recognising the field correctly.
As it is Atlassian who produce the expression framework, then I would be raising a support ticket with them as they will be able to confirm if there is any other way to do this.
I can confirm there are methods that can be called on a date field as documented here and these should be able to be called if the field is recognised as a date field but I would ask Atlassian to confirm why these cannot be called.
Yes, I understand the methods can be called on the date fields, but I'll definitely need to call these on date custom fields too.
Do you mean you are going to / have raised such a ticket with Atlassian? Can I be added as a request participant? Or should I raise it somewhere? Or is there any further documentation where this question can be answered?
Also, I know there is this https://scriptrunner-docs.connect.adaptavist.com/jiracloud/migrating.html#_migrating_from_scriptrunner_for_jira_server_to_cloud but is there a roadmap for Scriptrunner where dates are provided about which feature would be ready by when?
Thank you for all the info you are providing, this all still makes me understand Cloud Scriptrunner a little better!
I meant that you will need to raise a ticket with Atlassian which you can do here as the Jira Expression Framework is provided by Atlassian.
I can confirm we have a public backlog here where you can suggest features that you are interested in but we do not have any dates on when we will have the same features as the server version that we can share.