onRecordInsert: Different behaviour when changing record

Hi Servoy developers

To validate a record before inserting it into db, we validate user input in a method hooked to table event ‘onRecordInsert’. If the validation fails, we return false, true otherwise (as mentioned in several topics). Auto save is on.

Now we encounter the following problem (in Servoy 3.5.7 and 4.01):

There is a difference on how the user leaves the record (in the attached solution I always return false in the check):

  • When choosing alt + arrow down, everything works as expected: The selected record does not change. The user has to enter valid data before the record can be left.

  • Using the mouse or using the arrow down: The selected record changes and leaves the edited record in an unsaved and invalid state which leads to errors. Unless I reselect it and delete the new record.

Does anybody else encounter the same problem (I cannot believe we are the only ones)? We cannot force the user to always use ‘alt + arrow down’ to select an other record. Shouldn’t Servoy behave the same in the three situations described? Or is something wrong in the way we use onRecordInsert? An example in the documentation would be very helpful btw.

Thanks and regards
Birgit

brTest4.servoy (3.53 KB)

make a case for this with that solution attached in our support system

Birgit,

We have made a change in the Servoy client behaviour that should help in your situation.

First note that validation in the table events is not linked to the user interface so it is not possible to prevent the user from changing record when table events fail.
For example, actual saving of records can be delayed (auto-save off) in which case there is no link to the user-interface of the record anymore.

The change is in the response to the onRecordEditStop method.
When this method returns false it means the record data is invalid (this is existing behaviour).
Servoy is changed so that when record validation fails the user cannot leave the record, in record-view, list-view or table-view.

This new behaviour will be introduced in release 4.2.

Rob