Force an update of a form before navigating away

I am using a form in single record mode and encourage the user to browse through several records and update as needed.

As far as I can see the user needs to press ‘Save’ each time to save the record and if they navigate away to another record without doing this changes are lost.

  • is there a way to ensure it saves before navigating?
  • if not do I need a custom button to do this. If so how do I get script case to save a record?
  • if that’s not possible, can I generate an alert?

I’m worried users will spend time editing data and not realise the data isn’t being saved.

Thanks for suggestions…
Neil

Don’t tried but try with this JS



window.onbeforeunload = function () {
    nm_atualiza ('alterar');
};

Share your results :wink:

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.