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

Nicolay Subbota
Contributor
September 11, 2022

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 _Relational_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 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).

Nicolay Subbota
Contributor
September 12, 2022

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 _Relational_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 12, 2022

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

Alex Koxaras _Relational_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 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 :(

Like Tomas Slavkovsky likes this
Nicolay Subbota
Contributor
September 13, 2022

@Alex Koxaras _Relational_ thanks for the detail explanation.

Suggest an answer

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

Atlassian Community Events