How do I let the user create a new record?

Hi

The question looks so simple. But however I implement it, I run into a dead-end.
Here is what I currently do and what my problem is:

  • I set auto save off

  • I open a dialog on a new record

  • I let the user enter data

  • the user either cancels the dialog or commits it

  • if the user cancels the dialog: I delete the record, close the dialog and turn auto save on

  • if the user commits the dialog: I save the record

  • if save fails this is either because of onRecordInsert which returns false or because of a database error when e.g. not null attributes are not filled. But I do not get into the solution error handler where I get an exception and a reason for the error.

[/list:u]
[/list:u]
With auto save on I run into the solution error handler whenever I clicked outside of a field (via recordEditStop?). The error handler was ok but it was not ok that the user could commit the changes without using the save button. So I turned auto save off. But databaseManager.saveData() does somehow call other code than recordEditStop does, since I do no longer run into solution error handler. Puh!

Any suggestions? Regards
Birgit

birgit:

  1. if the user cancels the dialog: I delete the record, close the dialog and turn auto save on

I’m not sure to understand it completely but this is wrong, you don’t have to delete the record because the record has not been yet saved, just use databaseManager.rollbackEditedRecords().
At least it’s a starting point :)

Thank you! I’ll try this. Any starting point is very welcome.

I wonder how others solve this “simple” problem?

Best regards

I do what nicola suggested.

Does this mean:

  • set auto save to false
  • open dialog on new record
  • rollback transaction onHide form
  • validate user input when user clicks OK and commit transaction if validation is ok
    ???

Does anybody use auto save on when creating new records with a dialog?
Does anybody catch solution error for validation when creating new records?

Thank you and regards
Birgit