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

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
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Monday in Jira Software

How large do you think Jira Software can grow?

Hi Atlassian Community! My name is Shana, and I’m on the Jira Software team. One of the many reasons this Community exists is to connect you to others on similar product journeys or with comparabl...

546 views 6 12
Read article

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