Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,369,723
Community Members
 
Community Events
168
Community Groups

Jira automation email - incorect calculation {{now.diff([date2])}} in lookupIssues

Hi!

I try to configure some conditions based on manipulation with date.

I used this documentation - https://support.atlassian.com/cloud-automation/docs/jira-smart-values-date-and-time/ and https://support.atlassian.com/cloud-automation/docs/jira-smart-values-issues/

My example: 


Total issues with hot due date: <b>{{lookupIssues.size}}</b>

{{#lookupIssues}}
• <a href="{{url}}">{{key}}</a> <b>{{summary}}</b> <font color="darkolivegreen">[{{issueType.name}}]</font>
Assignee: <b>{{assignee.displayName}}</b>
This issue was updated at {{updated.longDate}} and has status <b>{{status.name}}</b> with priority <b>{{priority.name}}</b>
{{#if(and(exists(duedate),now.isAfter(duedate)))}}
Due date: {{duedate.longDate}}
<font color="red">Overdue: <b>{{duedate.diff(now).prettyPrint}}</b></font>
{{/}}
{{#if(and(exists(duedate),now.isBefore(duedate)))}}
Due date: {{duedate.longDate}}
<font color="green">On time: we have <b>{{now.diff(duedate).prettyPrint}}</b></font>
{{/}}
{{#if(and(exists(customfield_10026),now.isAfter(customfield_10026)))}}
Due date picker*: {{customfield_10026.longDate}}
<font color="red">Overdue: <b>{{customfield_10026.diff(now).prettyPrint}}</b>*</font>
{{/}}
{{#if(and(exists(customfield_10026),now.isBefore(customfield_10026)))}}
Due date picker*: {{customfield_10026.longDate}}
<font color="green">On time: we have <b>{{now.diff(customfield_10026).prettyPrint}}</b>*</font>
{{/}}
<hr>
{{/}}

---

For case "Overdue" when used "duedate.diff(now)" -  all is ok, the calculation is correct.

But for case "On time" when used "now.diff(duedate)" -  I have an issue with calculations - only first value is correct, and the following values are the same as the first one - please refer to picture when 5th and 6th values are wrong and must be "1 day" and "4 days" .

abc.PNG

1 answer

1 accepted

0 votes
Answer accepted
Alex Koxaras Community Leader Sep 12, 2022

Hi @Nicolay Subbota 

What type of field is the customfield_10026? And what do you expect this subtraction to yield? {{customfield_10026.diff(now).prettyPrint}}

On my instance, that specific field is Request Participants, and yes all results are the same. It makes sense though (I would produce an error to be exact).

Hi @Alex Koxaras 

On my side, customfield_10026 is a Due date picker (for some reason some tickets used only "Due date" and  some used only "Due date picker", so I must check these both fields)
Results example, from API response:

...

customfield_10026: "Due Date picker"

...

customfield_10026: "2022-09-15"

...

Alex Koxaras Community Leader Sep 12, 2022

Ok. Let me create a due date picker custom field and adjust my automation as well

Alex Koxaras Community Leader Sep 12, 2022

@Nicolay Subbota first of all I can confirm that this is...hmm...troublesome :)

I did all the necessary tests, and indeed the now.diff(customDATETIME) returns null. I've tried endless combinations to get this thing work, but none yield any result. It's safe to say that this is a bug and should be addressed to Atlassian's attention.

Unfortunately I wasn't able to find a workaround:

  • It doesn't matter if you format the date of both now and your CF. The difference between now-CF will always be null
  • I thought of storing the Due Date Time fields on a variable, but this variable is always text
  • The compare dates function however produces correct results

I didn't manage to find a workaround :(

@Alex Koxaras thanks for the detail explanation.

Like Alex Koxaras likes this

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
TAGS

Atlassian Community Events