I have spent the last few days banging my head against the wall with this one. I am looking for fresh ideas, or maybe a "thinking" outside of the box experienced InfoPath person that might have an idea I can leverage.
These are the facts:
1) I have a huge InfoPath form which is browser enabled and I am using the XmlFormView control in a custom web part. I have over 500 fields (yes, that many, and about 8 Views).
2) We have a make or break requirement which entails being able to track if the form is dirty, or basically if the user tries to navigate away from the current web page we prompt them "The form is not saved, are you sure you want to leave, etc". Again, this is within a web part zone and I need to figure out a way to resolve isdirty so any navigational link or attempt to close this web part page prompts the user.
This is what I've thought about/ruled out:
1) Using the Schema_Changed event (or root level node) and the FormState object within managed code at the client object/form level, I can verify when a change occurs. The problem is, I can't use this.NotifyHost() or a SubmitToHost.Execute() connection, since there has been no postback. This is not a UI button driven event, basically the client object form needs to tell the host or Server, "hey I'm dirty" with no user interaction or button even to drive post back. And there appears to be no way to simulate a button click on an InfoPath form (as a lessor hack of doom...).
2) At the browser level, I can write javascript to check some hidden field within the window.onbeforeunload event hander, but the problem is, I have no way to set it, given point 1. Handing the browser prompting is not the issue, its resolving the dirty status.
3) I can NOT have every field on the form auto post back to the server (under Browser settings in design view of InfoPath)and leverage a managed code changed event since its over 500 fields, this isn't practical since the IIS server would lag and every time the user changed a field value, it would re-send to the server, not a good user experience and we just can't do it.
4) Writing javascript to get the client rendered data array (var g_objCurrentFormData) that the XmlFormViewer uses. Basically get the array.ToString() MD5 hash it via javascript and then compare AGAIN against the data array resolved on window unload. Unfortunately, Forms Services scrubs through the data array and makes changes between window.onload and window.beforeunload, so I can't do this either...
So, I'm struggling and I'm not sure how else I can do this.
Any ideas? Can I extend Forms Services to use a new post back agent or trigger? Custom javascript that fires when a "tracker field" such as "Dirty_Field_Tracker" is updated to do a postback?
Has anyone been able to track the is dirty state of an InfoPath form through InfoPath Forms Services, some way of tracking if the form has changed?
Thanks for reading and any ideas are appreciated.
MK