Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Jira Automation Smart Value .toDate() and diff Failing with Custom Date Time Fields

Nathan T_ Gundy
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
May 7, 2025

Issue:

We are trying to use Jira Automation to calculate the duration between two custom Date Time fields ("Actual Start" and "Actual End") on an issue and populate that duration (in minutes) into a custom Number Field ("INC resolution time"). However, the smart values required for this calculation (.toDate() and diff) are not working as expected.

Automation Rule Setup:

  • Project: Incident Management (INC)
  • Trigger: Field value changed (on "Actual End")
  • Condition: Issue fields condition ("Actual Start" is not empty)
  • Actions:
    • Log action (to debug smart value output)
    • Edit issue (Set field "INC resolution time" with a smart value calculation)

Fields Involved:

  • Actual Start: Custom field, type Date Time Picker (ID: customfield_10524)
  • Actual End: Custom field, type Date Time Picker (ID: customfield_10525)
  • INC resolution time: Custom field, type Number Field

Problem Observed:

Initially, the "INC resolution time" field was not updating even with a static value (e.g., 999). This was found to be a permissions/workflow issue, which has since been resolved, and the field can now be updated by the rule with a static value.

However, when attempting to use smart values to calculate the duration, the field does not update, and debugging reveals the smart value calculation is failing.

Troubleshooting Steps Taken & Findings:

  1. Configured the "Edit issue" action to use the smart value {{issue.customfield_10525.toDate.diff(issue.customfield_10524.toDate).minutes}}} to calculate the duration in minutes.
  2. Added a "Log action" to output the raw field values, the result of .toDate(), the diff object, and the calculated minutes.
  3. Triggered the rule by editing the "Actual End" field on an issue (INCIDENT-1145) with valid "Actual Start" and "Actual End" dates/times.
  4. Examined the audit log for the rule execution.
  5. Critical Finding from Log Action: The log output shows the raw values for "Actual Start" and "Actual End" are correctly read (e.g., 2025-04-29T16:15:00.0+0000, 2025-05-06T13:40:00.0+0000).
  6. Critical Finding from Log Action: The log output shows that the smart values {{issue.customfield_10524.toDate}} and {{issue.customfield_10525.toDate}} are evaluating to empty strings or null ("ToDate Start:" and "ToDate End:" are blank in the log).
  7. Critical Finding from Log Action: Consequently, the smart value {{issue.customfield_10525.toDate.diff(issue.customfield_10524.toDate)}} is also evaluating to an empty object ("Difference object:" is blank), and {{...minutes}} is also blank.
  8. Attempting a direct subtraction smart value like {{issue.customfield_10525}} - {{issue.customfield_10524}} in the "Edit issue" action resulted in an error "Could not convert the field value to a number...", confirming that date fields are not treated as numbers for arithmetic.

Conclusion from Troubleshooting:

The root cause of the issue is that the standard Jira Automation smart value function .toDate() is failing to convert the raw values from our specific custom Date Time fields ("Actual Start" and "Actual End") into usable date objects. Because .toDate() is failing, the subsequent diff smart value cannot perform the duration calculation. Standard smart values do not offer an alternative method to convert these field values to date objects or perform date arithmetic.

Request:

Could you please investigate why the .toDate() smart value is not working as expected with our custom Date Time fields (IDs customfield_10524 and customfield_10525) and provide guidance on how to correctly convert these field values to date objects and calculate the duration between them using Jira Automation?

Thank you for your assistance.

2 answers

2 votes
Bill Sheboy
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.
May 7, 2025

Hi @Nathan T_ Gundy -- Welcome to the Atlassian Community!

The toDate() function converts a text value to a date / time: https://support.atlassian.com/cloud-automation/docs/examples-of-using-smart-values-with-dates/#Converting-text-to-dates

Your custom fields are already date (or date / time) picker fields, and so the conversion function is not needed.  Please try removing the functions and re-testing.

There are exceptions to this guidance, but they do not appear to apply for your rule:

  • the roadmap / advanced planning date fields appear as text (not date values) in automation rules
  • the special Jira Product Discovery (JPD) date fields, which are date-ranges implemented as JSON strings

Kind regards,
Bill

1 vote
Murat Seven
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.
May 7, 2025

Hi @Nathan T_ Gundy and Welcome to the Atlassian Community!

 

can you try this smart value;

{{issue.customfield_10525.diff(issue.customfield_10524).minutes}}

 

If the answer helps, please accept the answer.

 

Best regards,

Murat Seven

 

Suggest an answer

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

Atlassian Community Events