Some times our users open a record and accidentally change the values in that record.
Im trying to prevent this by having a method to ask them if they want to save the change to the record.
I have the following method that gets called on OnRecordSave, but it does not rollback the changes to the record:
var message = ‘Record has been modified. Do you want to save it? No to rollback, Ok to save.\n’;
var ALERT = plugins.dialogs.showInfoDialog( ‘Result’, message, ‘No’, ‘Ok’);
did you start a transaction when you entered the record? OnRecordSelect?
Anyway, I tried coding something similar a couple of weeks ago, and had to abandon the transaction approach. It worked well for a single user, but as soon as other clients try to save when a transactions is active, they will freeze until the first transaction is committed or rolled back.
A better approach may be to switch autosave off, and do a manually prompted save when leaving the record. I have never tried this myself, but I’m sure you’ll find some posts here on the forum…
I never work with onRecordSave, but I wonder when your code ever commits a transaction. controller.saveData() does not commit the transaction. You do a rollback, but where is the commit? Shouldn’t your code look like this: