Jira Automation rule to update due date when duration changes

Ann Rumenapp
Contributor
February 3, 2025

Using Jira Cloud (premium) for an automation rule to update the card due date when the WorkDuration of the card changes.  

WorkDuration is custom number field

Rule trigger is WorkDuration value changes. If WorkDuration is not empty, set Due date to the start date plus WorkDuration.image.png

Audit log gives me the following, and Due date is set to None.  What is missing in the smart value to set the Due date??  The rule results in setting due date to none.

image.png

 

Exact text for due date is: {{issue.start date.plusdays(WorkDuration).days}}

I'd rather have business days but using days because it's a shorter value.

 

1 answer

1 accepted

2 votes
Answer accepted
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.
February 3, 2025

Hi @Ann Rumenapp 

Assuming your WorkDuration field smart value is correct, please try this one, fixing some case errors and removing the "days" from the end:

{{issue.Start date.plusDays(issue.WorkDuration)}}

https://support.atlassian.com/cloud-automation/docs/jira-smart-values-date-and-time/#Date-plus-unit---

 

If that does not help, please try this how-to article to learn the name, spacing, and case for the field's smart values (or their custom field ID values): https://support.atlassian.com/cloud-automation/docs/find-the-smart-value-for-a-field/

 

Kind regards,
Bill

Ann Rumenapp
Contributor
February 3, 2025

THANK YOU!!  It was "issue.WorkDuration" for the fix

Like Bill Sheboy likes this
Ann Rumenapp
Contributor
February 3, 2025

Is it possible to create a variable with the change in value of WorkDuration? I've tried various combinations to add create a variable after the If WorkDuration is not empty without success....

I can get to the WorkDuration field values in log actions where Previous duration is 

{{fieldChange.fromString}} and current WorkDuration field is {{fieldChange.toString}}

 

I can't get the difference, of them to work so that a negative duration change can be applied to dependent cards.  I've used a few variations of smart values to get the difference: 

{{fieldChange.fromString.asNumber.diff(fieldChange.toString.asNumber)}} and

{{fieldChange.fromString.diff(fieldChange.toString)}} and

{{fieldChange.fromString.diff(fieldChange.toString).asNumber}}

All yield a null value in the audit log.

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.
February 3, 2025

The diff() function is for date / time values.

Please try using a math expression with those changelog values: https://support.atlassian.com/cloud-automation/docs/jira-smart-values-math-expressions/

Ann Rumenapp
Contributor
February 3, 2025

I'm sorry for being so dense....  Is there a way to get the audit log to show what it's doing with a calculation?

Thank you for the direction to use a math expression!  I was thinking this is logical comparison because the only way to get to the variable value was with 'String' in the smart value.

These give me a null answer in the audit log: 

{{fieldChange.fromString.minus(fieldChange.toString)}}

I also used: {{#=}}{{fieldChange.fromString}} – {{fieldChange.toString}}{{/}}

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.
February 3, 2025

No worries; we are all learning as we experiment with rule-writing.

You may use the Log action to write results to help with debugging, which I see you already have used in your rule.  For example I recommend writing these to the log for your rule to observe what they contain:

WorkDuration from and to String: {{#changelog.WorkDuration}}from: {{fromString}} and to: {{toString}}{{/}}

 

As that appears to be a number field, you could also try this for the difference, assuming no null values:

WorkDuration difference: {{#=}}{{#changelog.WorkDuration}}{{to}} - {{from}}{{/}}{{/}}

 

Ann Rumenapp
Contributor
February 4, 2025

I plan on putting an IF statement back in to make sure WorkDuration field is not empty.  Took it out until I can get the duration difference variable functioning.

I tried the WorkDuration difference formula and get a result of '-' in the audit log.  From the log actions the math should be 1 - 2 which is -1, but the audit log is showing '-'. Is there a Jira limit that doesn't allow negative numbers?

Rule: 

image.png

Audit Log: 

image.png

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.
February 4, 2025

Hmmm...the "raw" field values of {{from}} and {{to}} appear not to be working for that field type...or they contain other metadata which prevents the math.

Let's use a math expression with the string values in the Create Variable action:

{{#=}}{{#changelog.WorkDuration}}{{toString}} - {{fromString}}{{/}}{{/}}

 

Suggest an answer

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

Atlassian Community Events