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

This widget could not be displayed.

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

This widget could not be displayed.

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.

This widget could not be displayed.

@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
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted Wednesday in New to Jira

Are you planning to trial, or are currently trialling Jira Software? - We want to talk to you!

Hello! I'm Rayen, a product manager at Atlassian. My team and I are working hard to improve the trial experience for Jira Software Cloud. We are interested in   talking to 20 people planning t...

128 views 2 0
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