Automation for Jira - How to create a rule that when a Date field A is changed, edits Date field B and adds to/substracts from it the days difference by which field A was changed

Platform Notice: Data Center Only - This article only applies to Atlassian products on the Data Center platform.

Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Except Fisheye and Crucible

Summary

This article explains how to create a rule that automatically shifts a date field with the number of days which another date field was modified by.

Example: We have two Date type fields that are initially set as: Field A: 01/Jul/23| Field B: 20/Jul/23 When the Field A is changed to 08/Jul/23, we want automation to shift Field B with 7 days and set it to 27/Jul/23.

Solution

Create an Automation rule as below:

  • Add "Field Value Changed" trigger for Field A.

  • Add "Edit Issue" action and set Field B with the following expression:

    1 {{issue.Field B.plusDays(fieldchange.from.toDate.diff(fieldchange.to.toDate).days)}}

    The automation rule will look like in the screenshot below:

    Automation rule screenshot

Updated on May 31, 2024

Still need help?

The Atlassian Community is here for you.