Is this possible to evaluate the duration between a specified date on a form of a workflow, and the system date ? that what I want to do, in order to show (if this possible too) a short message if 1 day occurs since the specified date above, forbidding the transition of the status Closed to Reopened...
Thanks a lot,
As @Renjith mentioned, you can use the Script Runner plugin, plus the following code:
Date now = new Date() Date cfDate = new Date(cfValues['YourCustomField'].getTime()) new Date(now.getYear(), now.getMonth(), now.getDate()).compareTo(cfDate) <= 0
This is the script that should be placed in the Reopened transition as a validator.
*note: I've also answered you on StackOverflow. :)
The above code is a Groovy-based code which works well with the Script Runner plugin.
Yea, back to your question. You mentioned that the above code tests for comparison on whether the dates are identical. That is indeed true; however, since we are placing this in the validator for the workflow, it would return either true or false.
Hence, we are comparing the custom field with the current date (system date). If the custom field is former than the system date (>0), that would invalidate the transition and hence, blocks it.
Here's an example of it being done:
Maybe I could use dateCompare function ? or the following ... ?
I have to compare the closing date (specified on a form by an user) and system date. To explain, I would like to test :
IF system date - closing date <= 1 day THEN
allow transition from Closed to Reopened status
decline transition above, and return an error message to user.
Any help greatly appreciated.
thanks for sharing. . . this is very close to what I need.
however. . . This code
Date enteredTime = new Date(cfValues[customfield_10237].getTime())
and the logs shows this error. . .
groovy.lang.MissingPropertyException: No such property: cfValues for class: Script33
thanks in advance!
Connect with like-minded Atlassian users at free events near you!Find a group
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no AUG chapters near you at the moment.Start an AUG
We're bringing product updates and pro tips on teamwork to ten cities around the world.Save your spot