How to Find Which Item has Been Changed in APEX

I was recently developing an APEX page that had a lot of page items and a lot of Dynamic Actions (DA) on it. This is not usually a recommended approach (given that it can add complexity) but was justified given the business requirements. When testing the page I kept getting the This page is asking you to confirm that you want to leave - data you have entered may not be saved. when navigating away from the page despite not having explicitly changed any values.

If you’re not too familiar with how this message works / is configured read APEX: Warn on Unsaved Changes

I tried a few quick checks to see if I could isolate which page item was causing the issue but wasn’t able to easily find it. Instead I created a script to find out which page item had changed. Here is the script I created to find out which item(s) changed which is based on this article:

I’ve included a direct reference got Github Gist so that if updated it’ll be reflected here

A few notes / enhancements:

Once I found the problem item I could easily resolve why it was changing and the warning didn’t show up any more.

If you think there’s some additional elements that I should add to this list please update the Gist