Comment with SLA smart value fails in Jira Automation rule
Platform Notice: Cloud Only - This article only applies to Atlassian products on the cloud platform.
Summary
Automation rules designed to comment with Service Level Agreement (SLA) details (like "Time to resolution" remaining time or goal duration) may fail to populate correctly. Especially when used in rules triggered by work item creation, the comment might appear with blank values for the SLA fields or show the raw smart value string.
This can occur even if a "Delay execution" action is present in the rule. Example smart values that may fail in these rules include:
{{issue."Time to resolution".remainingTime}}
{{issue."Time to resolution".ongoingCycle.goalDuration.friendly}}
Solution
SLA calculation occurs after work item creation
The root cause is a timing issue related to data availability. In automation rules triggered by work item creation:
When a work item is created, the automation rule is triggered immediately
SLA calculations are processed by Jira shortly after the work item creation event
When executed, the automation rule is working with data as it existed before the SLA was calculated
Therefore, the smart values referencing SLA data resolve to empty or unavailable. That data isn't yet present in the work item that the rule initially fetched.
Use the "re-fetch work item data" automation action
To resolve this, the automation rule needs to be explicitly told to retrieve the latest version of the work item data after the SLA calculation completes.
Edit the problematic automation rule
Add a new action: "Re-fetch work item data"
Position this "Re-fetch issue data" action before the action that adds the comment (or performs any other operation requiring the SLA data)
If you have a "Delay execution" action, the "Re-fetch work item data" action should ideally come after the delay and before the comment action
Here's an example automation rule that accounts for the disparity between creation and SLA calculation:
Trigger: Work item created
(Optional) Action: Delay execution
Action: Re-fetch work item data
Action: Add comment
Comment body: <insert_SLA_smart_values>
Use Specific Custom Field Smart Values
While "Re-fetch work item data" is the primary fix, it's also good practice to use the custom field ID specific smart values for SLAs, as they can be more direct. For example:
Remaining time:
{{issue.customfield_XXXXX.ongoingCycle.remainingTime.friendly}}
Goal duration:
{{issue.customfield_XXXXX.ongoingCycle.goalDuration.friendly}}
Replace customfield_XXXXX
with the actual custom field ID for your "Time to resolution" SLA field. Please refer to Get custom field IDs for Jira and Jira Service Management for instructions on finding the ID of a custom field.
By incorporating the "Re-fetch issue data" action, the automation rule will query Jira for the most up-to-date issue details, including the now-populated SLA information, before attempting to use it in subsequent actions.
Was this helpful?