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}}.
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)
Original End Date
field to the current value of the End Date
.I hope it helps
Tuncay
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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();
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey thanks Tuncay! We'll amend and give it a go!
Best regards,
Karl. :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.