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:
- 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. - Added a "Log action" to output the raw field values, the result of
.toDate(), the diff object, and the calculated minutes. - Triggered the rule by editing the "Actual End" field on an issue (
INCIDENT-1145) with valid "Actual Start" and "Actual End" dates/times. - Examined the audit log for the rule execution.
- 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). - 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). - 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. - 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.