Similar to the behavior noticed when you lost focus on a new record, when the dialog is closed the new record tries to get saved, and will often fail due to reqired fields. I wrote a method that executes onhide the new record form (which is always displayed in a dialog)
The OnHide Method is supposed to do a check and rollback if needed.
It seems that the record tries to get saved before the OnHide method is called resulting in a database error.
I have set application.setFocusLostSaveEnabled(false) but this doesn’t seem to help when the new record being created is in a dialog.
Make sense I hope?
OnHide Method:
if (globals.GoodTransaction==0){
databaseManager.rollbackTransaction()
plugins.dialogs.showWarningDialog('Alert','New MemberCreation Cancelled','OK');
application.setFocusLostSaveEnabled(true)
}
if (globals.GoodTransaction==1){
controller.saveData()
application.setFocusLostSaveEnabled(true)
var success = databaseManager.commitTransaction()
globals.newpk=controller.getSelectedIndex()
if (!success) {
plugins.dialogs.showWarningDialog('Alert','Failed to commit data, did rollback','OK');
}else{
plugins.dialogs.showWarningDialog('Alert','New Member Successfully Created','OK');
forms.Member_Summary.controller.loadAllRecords()
forms.Member_Summary.controller.setSelectedIndex(globals.newpk)
}
globals.GoodTransaction==0
}