Most Elegant Way to Trap Dirty Records??

Hi Folks - as part of our move to Web Client we are dealing with the non operative autoSave() functionality. We will be adding a save and cancel button to all the data change forms.

First off it looked sensible to use the onRecordEditStop to indicate that a record had been edited but there are two challenges with that:

  1. Just entering a data field starts the onRecordEditStart - and consequently clicking anywhere else runs onRecordEditStop - even when there is no changed data.
  2. onRecordEditStop is run whenever the user clicks on any element except a data field, so even whilst moving to another tab in the same form to continue editing causes the event to fire.

I guess fixing up 1 is simply a matter of checking for hasRecordChanges and if not do nothing - though that seems inelegant to be honest.

Because our users need to click through several tabs on a form (same record or related data) they would be constantly firing the onRecordEditStop, and for sure we don’t want to keep asking them to save the data they have changed before changing to another tab etc.

So It looks like we need to check for hasRecordChanges whenever the user clicks the forward or back button or on form hide (many forms are deep in tabs so we cant use a global navigation form).

It would seem more logical if onRecordEditStop was actioned when the user attempts to leave the record in some way (move to another form or select a different record), as it is shouldn’t more logically be called onColumnDataEdit or some such. But as it is I don’t think it will work for us.

We will need to do this on dozens of forms and I suspect because of the above we will need to modify the next/previous navigation and the onHide on each of these forms - and since many of them already have these events defined its really hand coding.

Is there a better way to handle this, or perhaps a way to press the onRecordEditStop event into use here without driving the users crazy with warnings to save?

Appreciate feedback on how others handle this.

Revisiting this concept:
EDITED:

EDITED:Whenever a user clicks into a text box - even when not editing the record but just giving it the focus with the mouse, it seems the onRecordEditStop fires when anywhere else on the form is clicked outside a text box. Is this correct - as obviously the record has not been edited in this instance.

Also ```
databaseManager.hasRecordChanges(foundset)


Some custom valulists are populated at onLoad and there is a a couple of column updates in the onShow, but they are saved as they are calculated - so there are no outstanding edits when the onRecordEditStop is fired - and the saveData = false.

How can this be trapped such that the onRecordEditStop can be used for validation purposes?

EDITED: Having revisited this I realised I could select the record to check for changes (foundset,1) and that specifies if there are data changes in the current record.

EDITED: However - it still bugs that the onRecordEditStop simply acts as an onFocusLost in reality but for data fields rather than a specific field (as onFocusLost actually does) - it fires regardless of what's happening in the record data??

Appreciate feedback. What am I missing here???

OK - Moving on to try and get this running as a proof of concept for myself.

I’ve now got my hasChangedRecords running on the onHide event of the form. Essentially if the user moves to another form or menu selection the code alerts him to unsaved changes.

I’d like this to run on the onNextRecord and onPreviousRecord - but for whatever reason it does not seem to run when set in those events.

I do have some nav buttons on the form where stepping from one record to another is handled - however I was under the impression that the events of onNext and onPrev would fire regardless of how the record was navigated??? My form function is simply not being fired by these events.

Is this assumption incorrect??