rollback does not work

Hi

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?

Thanks for any help and regards
Birgit

When you enter the form you have to set the autosave to false: ```
databaseManager.setAutoSave(false);

As a result, nothing will be saved into the database before you do "databaseManager.saveData();"

I do set auto save to false before I open the dialog:

set auto save to false;
new record;
open dialog
set auto save true;

Can anybody reproduce this?

Regards
Birgit

Birgit,

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?

Hi Johan

Thank you for your answer.

Would it be a soultion to set the failed record to edit mode somehow? Or how can I rollback to the state before creating the new record?

Here is what I do in more detail:

databaseManager.setAutoSave(false);
controller.newRecord();
application.showFormInDialog(forms.PrfDialogX);
databaseManager.setAutoSave(true);

An in the dialog on save command:

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?

Thanks and regards

i fixed the thing you are describing for the next versions of servoy

what you can do is just touch the failed records
for example loop of them and just set a specific field to something else

then do the rollback

Thank you for understanding my example, fixing the problem and offering a workaround. :D

Regards