It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Safely Deleting Change History Records Edited

I have a number of derived fields which create noise in the issue change log. I'd like to remove these from the log.

I've had a read of and take note of the warnings. I've also had a look at the code for com.atlassian.jira.issue.changehistory.removeAllChangeItems(Issue issue) in order to understand what it is doing and adapt it to my needs.

I'm wondering if the following code is the correct/safe way to delete change items, without needing to shutdown and restart the service.

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.changehistory.ChangeHistoryManager
import com.atlassian.jira.issue.changehistory.ChangeHistory
import com.atlassian.jira.entity.Entity
import com.atlassian.jira.ofbiz.OfBizDelegator

List<String> fieldsToRemove = ["Field Name 1", "Field Name 2", "Field Name 3"]

ChangeHistoryManager changeHistoryManager =
JsonEntityPropertyManager jsonEntityPropertyManager =
OfBizDelegator ofBizDelegator = ComponentAccessor.getOfBizDelegator()

List<ChangeHistory> history = changeHistoryManager.getChangeHistories(issue)
history.each{ChangeHistory ch ->
Boolean allDeleted = null
ch.changeItems.each {
Long changeItemId = it.get("id")
String field = it.get("field")
if (fieldsToRemove.contains(field)) {
if (allDeleted==null) {
allDeleted = true
[id: changeItemId].asImmutable())
} else {
allDeleted = false

if (allDeleted) {


0 answers

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Marketplace Apps & Integrations

Cloud Cafe Ep. 4: Listing your app on the Atlassian Marketplace

Hey y’all! Grab a cup of ☕ and check out the latest installment of Cloud Cafe – our video series about cloud app development on Atlassian. If you’re new to Cloud Cafe, check out the first few episo...

20 views 0 1
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you