Set the field value based on custom date value

Lakshmi S
Contributor
February 10, 2021

Hi Team,

I am on jira server (8.7.1), and available addons are JMWE, scriptrunner, JSU, etc. I am trying to achieving through JMWE (Set Field Value function), but i did not find any date function on within 24 hours of creation date.

The requirement is,

If Need By Date is within 24 hours of Creation date, then Escalation? field must equal 'Yes'.

I am trying with issue.get("Need By Date") == (new Date().clearTime() >= -24h

Could anyone please help on this correct function ?

Thanks!

 

2 answers

1 accepted

0 votes
Answer accepted
David Fischer
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 10, 2021

Hi @Lakshmi S ,

you can use this code as the conditional execution script of the Set Field Value post-function:

issue.get("Need By Date").time < (new Date()).time + 24*60*60*1000

  The value of the post-function is Yes, and of course the field is Escalation

Lakshmi S
Contributor
February 10, 2021

@David Fischer, Thank you soooooooooo much. Its working as expected.

0 votes
Aiden Marriott
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.
February 10, 2021

If you output those two values to the log file what do they say? 

You may be comparing a string object with a date object which will never be equivalent

This would only work if the date was exactly 24h ago.... you probably want two date objects and want to check if the date set is equal to or less than to +24 hours.

Lakshmi S
Contributor
February 10, 2021

Hi @Aiden Marriott ,

 No, we are not comparing string object with date. The date custom field (Need By date) is within 24 of ticket creation date, then change the "Escalation" field value to YES in the ticket.

If Need By Date is within 24 hours of Creation date, then Escalation? field must equal 'Yes'.

 

Thanks!

Suggest an answer

Log in or Sign up to answer