Jira Automation - Smart value: Difference between 2 timestamp custom fields in a 3rd custom field

Anand Chittoor November 2, 2021

Hello, 

Looking for some help here. 

I have researched many community solutions (by @Ravi Sagar _Sparxsys_ , @John Funk, and @Nir Haimov  but still stuck at the last hurdle.

I have the following custom field's below for which automation is working fine. These are timestamp fields.

I want to populate another custom field (number) Time to First Reponse (TTFR), which is the difference between the "Acknowledged timestamp" and "Ready status timestamp", ideally in businessDays. Hours will work too if need be.

Screen Shot 2021-11-02 at 10.04.12 AM.png

I have tested my automation conditions trying to hard code the TTFR edit issue to a number (2). and it populates fine. But when I insert the below formulae, the automation log shows success, but there is nothing outputted in the TTFR field.

-Formulae i have tried under "edit issue" 

  • Acknowledged Timestamp - customfield_14475,
  • Ready Timestamp - customfield_14474

{{issue.Customfield_14474.diff(issue.customfield_14475).hours}} 

or

{{issue.customfield_14475.diff(issue.customfield_14474]).businessDays}}

 

SCREENSHOTS - 

Screen Shot 2021-11-02 at 10.07.56 AM.png

1 answer

1 accepted

0 votes
Answer accepted
Lisa Grau
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.
November 2, 2021

Hi Anand,

I recreated your use case and this solution worked for me:

{{issue.Uhrzeit 1.diff(issue.Uhrzeit 2).businessDays}} -> returned the difference in days

{{issue.Uhrzeit 1.diff(issue.Uhrzeit 2)}} -> returned the difference in hours

What type is the field you are editing? I used a textfield which works fine.

"Uhrzeit 1" and "Uhrzeit 2" are my test fields.

Anand Chittoor November 2, 2021

Thanks lisa. I've tried number and now text as well. no results. I've also tried changing custom field reference from IDs to names. 

Anand Chittoor November 2, 2021

@Lisa Grau Whats your automation rule? screenshot?

Anand Chittoor November 3, 2021

@Lisa Grau  - "Uhrzeit 1" and "Uhrzeit 2" are these date time picker fields?

For me - 

customfield_14475 and issue.customfield_14474 are date time picker fields and I am trying to calculate the difference to store the result in a custom field (Text Field (single line)) field. Ive also tried a number field.

 

Anand Chittoor November 3, 2021

Here's my audit log for the automation (success) for the result custom field... Result - Time to First Response (my result custom field - text) is "None".

Screen Shot 2021-11-03 at 1.17.34 PM.png

Lisa Grau
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.
November 4, 2021

I'm sorry I couldn't manage to answer yesterday!

Both fields are Date Time Picker.

This is what my automation looks like:

2021-11-04 12_16_08-Project automation - Jira.png

Anand Chittoor November 4, 2021

Thank you Lisa. Magically, this worked this morning for new issues. I appreciate your responses.

Anand Chittoor November 5, 2021

Update - my automation still had issues. The first time the value for "Update for Customer" field changed, the automation for the calculation ran successfully but no results as earlier.

Interestingly, the second time the "Update for customer" field is changed, the results were successfully outputted in the screen.

My analysis (by using @Lisa Grau manual trigger idea, suggested me value change triggers were causing it. 

 

I just solved the issue by creating a manual trigger like Lisa suggested to run every night at 12 am. 

 

Thank you again. Hope this helps someone else with the same problem.

Like # people like this
Deepak Prasanth March 31, 2023

Hi there,

I am also trying something similar and I was advised to look here but still can't figure it out.

 

Problem statement - We have two customfields defined: Time for Approval [in seconds] and Time for Resolution [in seconds], we are trying to do something like below but unable to get the customfield value.

 

Time to approve [customfield_XXXX] = {{issue.created.diff(now).seconds}} -- this works fine

Time to resolution = {{issue.created.diff(customfield_XXXX).seconds}} ---not working

 

Please suggest.

Suggest an answer

Log in or Sign up to answer