Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Compare custom date field value to created date field value

Lakshmi CH
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 7, 2020

Hi 

I want to set the Priority to Major when the below condition is true, I have used "set field value (JMWE for jira server)", but it not setting to Major. Could you please anyone correct the equal script ?

 

(issue.getAsString("Issue Type") == "Change Request" || issue.getAsString("Issue Type") =="Bug" ) && issue.get("Need By Date") == new Date()

or

(issue.getAsString("Issue Type") == "Change Request" || issue.getAsString("Issue Type") =="Bug" ) && issue.get("Need By Date").equals(new Date())

 

 

but these are working,

(issue.getAsString("Issue Type") == "Change Request" || issue.getAsString("Issue Type") =="Bug" ) && issue.get("Need By Date").before( new Date() )

and

(issue.getAsString("Issue Type") == "Change Request" || issue.getAsString("Issue Type") =="Bug" ) && issue.get("Need By Date").after( new Date() )

1 answer

1 accepted

0 votes
Answer accepted
David Fischer
Community Champion
July 7, 2020

Hi,

that's because Date objects contain both a date and a time component, so new Date() returns "now", not just "today". To return "today", use:

new Date().clearTime()
Lakshmi CH
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 10, 2020

Thank you for your quick response @David Fischer . Its working.

(issue.getAsString("Issue Type") == "Change Request" || issue.getAsString("Issue Type") =="Bug" ) && issue.get("Need By Date").equals(new Date().clearTime())

Ganesh
Contributor
July 28, 2022

Hi,

The same scenario, but i have to add the project name as script here.

Ex: Project ABC and Project XYZ and Issutype stories. But i want to implement this only for project ABC bugs not for project XYZ.

Thanks in advance.

 

Best,

Ganesh.

Suggest an answer

Log in or Sign up to answer