How to compare due date and system time (date) and make other field required?

Hi!

In our case we need to compare two dates in creation stage, and if due date = 2 days or less, make reason field required.

In my imagination with simple script validation is ugly, but seem like this:

if (issue.dueDate) {
    if (issue.dueDate.<=2(Calendar.getInstance().getTime())) {
 cf (1000) is required

Please help me to sort out.
Thanks! 




 

3 answers

1 accepted

Accepted Answer
2 votes

something like this:

import java.util.concurrent.TimeUnit

def twoDaysFromNow = new Date(new Date().time + TimeUnit.DAYS.toMillis(2))

if (issue.dueDate && issue.dueDate.before(twoDaysFromNow)) {
    return cfValues["Reason"] as boolean
}

Hi Jamie! I test it: If i fill any Due the Reason field is required always. And if i fill in Reason field Jira is continue ask me to fill it again.

I didnt' test it and made a typo, I've changed it now

Ok, Jamie thank you! I Checked it again, but problem still actual: "Reason" field is required (always).

this is simlpe scripted validator? Add a new line at the end: true

Jamie, yes it is it. Its work now! THANK YOU!

Hi, I am trying following code.please let me know if it wrong. import java.util.concurrent.TimeUnit def today = new Date() if (today == issue.issue.fixVersions*.releaseDate) { return cfValues["RCT Late Approval"] as boolean } Thank you so much in advance....

Hi Suresh, import java.util.concurrent.TimeUnit def today = new Date() if (today == issue.issue.fixVersions*.releaseDate) { return cfValues["RCT Late Approval"] as boolean } true

Hi Jamie!

May be you know why script is does not work in production environment, but work fine on test environment.

Addon Version is same.
JIRA version is same.
Fields naming is same.

Please help us!

 

Did you solve this? There's no reason it shouldn't work afaik.

@Jamie Echlin [Adaptavist]

Hi Jamie!

May be you know why script is does not work in production environment, but work fine on test environment.

Addon Version is same.
JIRA version is same.
Fields naming is same.

May be import java.util.concurrent.TimeUnit does not work?

When reason field is filled JIRA still ask me to fill it again.

Please help us!

 

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Tuesday in Jira

Looking for anyone who made the switch to Data Center

The Jira Marketing team is putting together an ebook on migrating to Data Center. We're looking for pro tips on how you staffed your project team and organized your Proof of Concept. Share yo...

35 views 0 2
Join discussion

Atlassian User Groups

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!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you