variable is not recognized in date diff function in jira automation

Anna April 30, 2024

Hi there,

I have a custom field of Date picker type (Groomed Date) and can retrieve the value successfully as a variable and from smart value as well. However, when try to use the variable in DIFF function, it returns null.

Here is automation rule flow:

1. The first variable is mynowdate = {{now.jiraDate}}

Log value: mynowdate - 2024-04-30

2. the second variable mygroomdate = {{issue.customfield_21231.jiraDate}}.

Log value: groom date: 2024-04-01

3. The final compare in email body looks like this:

diff1 - {{now.jiraDate.diff(issue.customfield_21231.jiraDate).days}}
diff2 - {{"mynowdate".jiraDate.diff("mygroomdate").days}}
diff4 - {{mynowdate.jiraDate.diff(mygroomdate).days}}

All these 3 lines return null where custom field is Date picker type, however this works with another field of DateTime picker (Begin Date) and the line below does calculates the difference:

diff2 - {{now.diff(issue.Begin Date).days}}

Why automation returns null with Date picket field? What do I do wrong?

We use Jira Data Centre.

1 answer

1 accepted

2 votes
Answer accepted
Kalyan Sattaluri
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.
April 30, 2024

Hello @Anna 

When you store your value in a variable, it is getting stored as text. And so when you do a diff on 2 variables, it is not giving you expected results, OTOH, in  {{now.diff(issue.Begin Date).days}} you are directly referencing the date field.

so you either reference the fields directly like: {{now.diff(issue.customfield_21231).days}} OR

you convert your variables to Date and then do diff like: {{mynowdate.toDate.diff(mygroomdate.toDate).days}}

Hope it helps.

 

Anna April 30, 2024

I spent a few days trying to figure out and did a lot of research on internet.

The last line worked for me - {{mynowdate.toDate.diff(mygroomdate.toDate).days}} and calculated difference as expected.

I will mark this as answered

Thank you so much!!!!

Like Kalyan Sattaluri likes this

Suggest an answer

Log in or Sign up to answer