In an “onClose” method you can return false to prevent Servoy from closing.
With reference to several threads on the forum concerning wanting to validate data before saving to the backend database, what about having the same functionality for “onRecordSave”?
I’d like to cancel the saving of a record if I detect a problem to avoid getting an error message back from the database.
if(people_name == null || people_type == null) {
//no point in trying to save this
//lets display a required fields message to the user
//and leave them take them to the first required field
plugins.dialogs.showErrorDialog( "Error","Some required fields need to be filled in.","OK");
people_name.requestFocus();
return false;
} else
//everything ok
return true;
}
This could save us from having to write many 'F***Maker"-style workarounds.
I have exactly the same problem of swingman, but I cannot use a transaction, as proposed by Bob Cusick, because I am already inside a larger transaction,
I tried to use application.setFocusLostSaveEnabled(false) - this is what Johan Compagner suggests - to disable the record auto-save, but with no success. I thought application.setFocusLostSaveEnabled(false) worked at record level, even if triggered by a field. But, on a different thread, Robert J.C. Ivens, suggested that application.setFocusLostSaveEnabled works at field level, e.g. it enables/disables save only when one gets out of a field, but if one moves to the next record the modifications are saved anyway.
If this is the expected behaviour of application.setFocusLostSaveEnabled(false|true), it is almost useless because if a user moves back or forward using the menu commands he/she overrides the application.setFocusLostSaveEnabled command and there is no way to prevent him/her from doing so. Unless I toggle the forms command, but this means losing a functionality.
will turn of autosave completely only the developer can call in a method
databasemanager.saveData()
Anything else will never save. (maybe a few very special circumstances it will but)
also the onRecordSave event can return false. This will stop the save to a database. (of everyting that is in the todo save list!)
So you can create or update records everwhere if you want on multiply forms and relations. And if the main form then blocks the save nothing will save yet. Until everything returns true (that it can save) and saveData is triggerd somehow.
That’s really good news, thank you for the information and I look forward to Servoy 3.0.
In the meantime I solved my problem using a method fired by OnSave event: all original values of the fields which require an explicit save are stored in an array to be used in case the save is cancelled.