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: Server and Data Center only. This article only applies to Atlassian products on the Server and Data Center platforms.
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.
Environment
- Jira Server / Data Center 8.0.0 and any higher version
- Automation for Jira 7.0.0 and any higher version
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:
{{issue.Field B.plusDays(fieldchange.from.toDate.diff(fieldchange.to.toDate).days)}}
The automation rule will look like in the screenshot below: