Trying to delete Change History for single records

Question / Problem

An organization I work with started a new partnership that requires personal information and details to occasionally be expunged (name, phone numbers, etc). We will need to keep some information from the record, so don't want to delete it outright.

The issue is that we currently have the Change History feature enabled for this app, allowing the information we want to delete to still be discovered. We would like to keep Change History enabled for the app, but it makes sense that there is no native menu to delete it.

Current Situation

I poked around the API docs and there doesn't seem to be any reference to Change History.

The closest thing I could find is the response from Get Record includes the Revision field, but this can't be updated and there doesn't seem to be a way to lookup/update/delete specific revision numbers of a record through the API.

I plan to suggest disabling Change History for the app as the best solution. I will also explore using the API's to create a new record that copies the data we want to keep in (but this might create more headaches from a new record ID than it's worth).

##Desired Outcome
Before I go too much further I wanted to post the question in case I'm missing a potential solution through the API to delete the history from a single record?

Thank you for any input!

Referenced Resources

Hello @jared_rogers
Welcome to the community!

From my understanding, you occasionally need to delete information from records but still want to track these changes using the Change History feature for future reference. However, if these change records are no longer needed, you would also like to delete them from the history tab. Please confirm if this is accurate.

Hey Chris,
Thanks for clarifying, I think your understanding is correct. To try and clarify further:

We occasionally want to delete information from a record with No ability to ever recover that information in the future/view it in change history.

I don't think it would matter whether we were deleting a single change from the history tab or all the change history for the record, as long as we could delete any history that still recovered the information we are trying to delete.

If possible, for any other records in the app (that we don't need to comply with a record expungement for) it would be helpful to still see change history as you normally would with the feature enabled.

Hello @jared_rogers

Thank you for your reply!

The Change History feature in Kintone is designed to provide an audit trail of record changes, and this audit trail cannot be modified or deleted programmatically or manually.

To manage record expungement, I guess you have a couple of options:

  1. Custom Logging: Disable the Change History feature and implement custom logging within your records through scripting. This approach can be complex but offers detailed control over data retention and deletion.

  2. Hide History Tab: This option is simpler. You can enable the Change History feature and then hide the history tab and its content through scripting. Note that this approach hides the history even for records that don't require compliance with record expungement. If you need to view the history temporarily, you can disable the script. However, please be aware that this involves DOM manipulation, and while Kintone supports UI customization via JavaScript, regressions may occur after Kintone updates.

Here's a sample script to hide the tab and its content:

(function() {
    'use strict';

    function hideChangeHistoryElements() {
        // Hide the Change History button/tab
        var historyTab = document.querySelector('a.goog-tab.sidebar-tab-history-gaia');
        if (historyTab) {
            historyTab.style.display = 'none';
        }

        // Hide the Change History panel
        var historyPanel = document.querySelector('ol.itemlist-gaia.itemlist-gaia-history');
        if (historyPanel) {
            historyPanel.style.display = 'none';
        }

        // Attempting to hide other potential elements related to Change History
        var historyItems = document.querySelectorAll('.itemlist-gaia-history, .history-panel-gaia');
        if (historyItems.length > 0) {
            historyItems.forEach(function(item) {
                item.style.display = 'none';
            });
        }
    }

    function delayHideChangeHistory() {
        requestAnimationFrame(hideChangeHistoryElements); // Use requestAnimationFrame for immediate execution
    }

    // Observe changes in the DOM to hide Change History elements
    var observer = new MutationObserver(delayHideChangeHistory);
    observer.observe(document.body, {
        childList: true,
        subtree: true
    });

    kintone.events.on(['app.record.index.show', 'app.record.detail.show'], function(event) {
        delayHideChangeHistory();
        return event;
    });

    // Immediately hide Change History elements when script loads
    hideChangeHistoryElements();

})();

This script will hide the Change History tab and its content effectively. Adjust the script as needed for your specific requirements.