I appreciate that this is an old post I am replying to - perhaps this is an indication of how much this is a festering problem…
In my experience, the proposed solution does not work in this situation. In the situation described (record navigation, not form navigation) the form is not unloaded - a new record is simply loaded into the existing form. The event never fires. And yes, I did try it.
This solution works well when navigating to a different page, but not different records.
I have not been able to find a solution to warn the user if the record is not saved when navigating between records .
The issue is that I have not been able to find a way to check if the current record has been changed before the record navigation occurs. For example, I often create a hidden field which is set onLoad to indicate not modified ({modified} = “N”, for example). I then use js to set the hidden field to indicate the record has been modified ({modified} = “Y”) when changed (using js onclick or onchange). But the scriptcase onNavigate event is only fired AFTER the new record is loaded - the hidden field is therefore reset to “N” and any test to see if the previous record was modified will not work.
Unfortunately you cannot use a global variable to test if the record is changed (instead of the hidden field) because there does not seem to be a way to set global variables from javascript events when fields are changed.
Unless someone else has an answer, there isn’t one that I can find.
It would be very useful for SC to change ‘onNavigate’ to ‘afterNavigate’ and implement a new ‘beforeNavigate’, the latter having the ability to test for the changed record and warning the user that they have navigated away from a changed record without saving it - even if the framework doesn’t allow you to save the record itself at that time.