Hi there,
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,
Christophe
Hi Christophe,
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. :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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:
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.
Awww, and I was just writing the code for this! :D
Nevertheless, good work on finding it, man! We can share these two scripts out for all to see! :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yeah, if you can use Script runner. Add a validator and do the test inside that. https://jamieechlin.atlassian.net/wiki/display/GRV/Script+Runner
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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!
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 must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
ELSE
decline transition above, and return an error message to user.
END
Any help greatly appreciated.
Best regards,
Christophe
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Did you read my reply above?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes, thanks but I did not find a sample for my purpose :-(
I'm still looking for one solution ...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.