By using the Revert Records script with the "Perform without dialog "button clicked,i got my desired result.
Careful. If the user clicks the layout background during data entry, some of the data could have already been committed and thus revert wouldn't work.
You may want to use global fields for data entry and the script to "Enter" the data can move the data from the global fields into fields of the new record.
Then undo is simply a matter of clearing the global fields.