I have a Date Picker field in a form called Start Date. I am trying to create a condition in a workflow that checks that this date is greater or equal to today. I am trying to do this with the Universal Condition of the JIRA Workflow Enhancer plugin but as the Date Picker defaults the time to 00:00:00 a Start Date of today is actually midnight last night. So the boolean equation:
"{Date Due} >= [now]" will actually be False as [now], a default variable in the Universal Condition plugin, includes the time which is obviously greater than 00:00:00.
I have tried to use "{Date Due} >= [now] - 1d" which sounds to me like it should work, but doesn't and always returns False. How can I get a condition which allows for a date picker set to today, regardless of time, to return True when compared to the [now].
Just for information I have also tried things like "[now] - {Date Due} <= 1min", "{Date Due} + 1d >= [now]", "{Date Due} >= [now] - 1d" etc. but nothing seems to work!
If the Universal Condition isn't a possibility, does anyone have any other ideas as to how to achieve this? Remember that I am using a date picker only, NOT a date and time picker (for good reason).
Many thanks.
James.
Or use JJupin https://marketplace.atlassian.com/plugins/com.keplerrominfo.jira.plugins.jjupin if you want to do it easily:
Code should look like:
return startOfDay(customfield_10101) > startOfDay(dueDate); //or whatever
Hi Radu,
Thanks for your response. The plugin that you mention is a costable plugin, and whilst it is not that expensive I was hoping to achieve this without any cost at all. Thanks again.
James.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Sure, I can understand that.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Not sure of this add-on that you are using but you can use this add-on instead.
https://jamieechlin.atlassian.net/wiki/display/GRV/Script+Runner
import com.atlassian.jira.ComponentManager import com.atlassian.jira.issue.Issue import org.apache.log4j.Category passesCondition = false; Date date = issue.getCreatedDate(); Date now = new Date(); // Do date comparison return passesCondition;
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Timothy,
Thanks for this. Would be good to try this out. However, i have failed at the first hurdle. I have searched for script runner in the Universal Plugin Manager as the help on your site suggests but I cannot see your plugin appear. What is its actual name? There is one called Jira Scripting Suite. Is it this one?
Many thanks
James.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Timothy,
Thanks for this. I am trying to give it a go. Had this plugin installed already actually, just never really used it so not really sure what I am doing with the programming elements! Anyway, I have tried this script:
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.Issue
import org.apache.log4j.Category
passesCondition = true;
Date dateDateDue = $issue.getCustomFieldValue("customfield_10080");
Date dateNow = new Date();
// Do date comparison
#if (dateDateDue < dateNow)
passesCondition = false;
invalidInputException = new InvalidInputException("Date Due cannot be in the passed.")
#end
return passesCondition;
My date field that I am wanting to compare to today is a custom field "Date Picker" with ID 10080. However, this, when saved in a file C:\Program Files\Atlassian\JIRA\atlassian-jira\JavaScriptFiles\ValidateDateDueScript.groovy and referenced in the "Script Validator" file path property of a workflow validator, gives the following error when I try to transition a ticket via this workflow:
"An unknown exception occured executing Validator com.onresolve.jira.groovy.GroovyValidator@4ac5b7: root cause: java.lang.NullPointerException"
What might I be doing wrong?
Many many thanks.
James.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Timothy,
I was wondering if you would have chance to comment on the above? I would really appreciate it. I am sure this is something really simple, but the programming side of Jira is not something I am familiar with.
Many thanks for any help you can offer.
Take care
James.
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.