I create a new record and let the user edit it with a dialog. If the dialog gets cancelled, I execute
databaseManager.rollbackEditedRecords();
If the user clicks save, I execute
databaseManager.saveData();
If the save fails and the user cancels the dialog after, the rollback does not work any more. Which means, the record hangs around in the form, unsaved. Only if the user reopens the form, the view is updated.
I got the impression this worked months ago, but I’m not sure.
Q1: Did the behaviour change?
Q2: How should this be done? Should I delete the record instead of run a rollback?
i think your problem is that when a save fails.
Your failed records are not in the “editing records” any more but in the “failed records”
(they will go out of the failed records when you touch them again)
and i think i see a problem here. What happens if you touch 1 record again (a failed one or another one)
so that 1 record goes really into edit again? And then you do rollback?
I guess that it works then?
databaseManager.saveData();
if (databaseManager.getFailedRecords().length == 0)
{
application.closeFormDialog();
}
else
{
plugins.dialogs.showErrorDialog('Error', 'Cannot be saved', 'Ok');
}
The problem occurrs, if the save fails and the user cancels the dialog after. Then I tried a rollback. I do not see what the rollback does in this case. The record of course was not (never) saved in the database but stays visible in the UI. So I assume it is still in the foundset. And foundset and DB are out of sync. So instead of doing a rollback - as suggested in the forum - I do a controller.deleteRecord(). Is this the right way to do?