Recalling a historical End date

Karl Samson
Contributor
June 27, 2024

Hi Guys, 

How do I recall a historical date eg. the End Date is changed, and then displaying that original date using a Smart value in a 'Send Email' Automation?

Eg. (Original) End Date - {{issue.customfield_13302}}

      (Changed) End Date - {{issue.customfield_13303}}.

1 answer

1 accepted

0 votes
Answer accepted
Tuncay Senturk
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 27, 2024

Hi @Karl Samson 

You can accomplish this in different ways. One method is to write a script that checks the change history items for the field and retrieves the original value from the issue history. It's straightforward to obtain the old value of any field using a Groovy script.

However, if you prefer not to write code, you can achieve this using Automation. I'm not sure how many fields you want to track the original value for, but I wouldn't recommend doing it for every custom field. I assume you only want this for a field or two. Here is the solution for this.

  • Create a custom field to store the original date (for End Date field which is customfield_13302): Original End Date (say it is customfield_13303)

  • Set up an Automation Rule to capture the original date
    • when the End Date field is updated.
    • Use the Edit Issue action to set the Original End Date field to the current value of the End Date.
  • Use in Send email Automation
    • (Original) End Date - {{issue.customfield_13302}}
      (Changed) End Date - {{issue.customfield_
      13303}}

I hope it helps

Tuncay

Karl Samson
Contributor
June 27, 2024

Hi Tuncay, thanks for your response! Yes, we had considered creating a hidden Custom field called 'Original End Date', that would populate once the first 'End Date' entry was made. Then calling on that in an Automation, once the 'End Date' field was updated.

But we would be interested in scripting it too. 

Can you suggest the code for doing this please?

Best regards,

Karl.

Tuncay Senturk
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 27, 2024

Of course,

Below I am sharing a code snippet for you to start with but please bear in mind this is just a sample code I wrote here, I haven't tested it. fieldName is the fieldId that you want to track.

 

import com.atlassian.jira.issue.changehistory.ChangeHistoryManager;
import com.atlassian.jira.issue.history.ChangeItemBean;

def changeHistoryManager = ComponentAccessor.getChangeHistoryManager()

List<ChangeItemBean> changeItemListForField = changeHistoryManager.getChangeItemsForField(issue, fieldName)

for(ChangeItemBean changeItem: changeItemListForField){
        String newValue = changeItem.getTo();
  String oldValue = changeItem.getFrom();
}
}
Karl Samson
Contributor
June 27, 2024

Hey thanks Tuncay! We'll amend and give it a go!

 

Best regards,

Karl. :)

Like Tuncay Senturk likes this

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
VERSION
9.12.8
TAGS
AUG Leaders

Atlassian Community Events