AnsweredAssumed Answered

Possible Bug:  OnRecordRevert script trigger, + Exit Script with result 0

Question asked by AHunter3_1 on Nov 4, 2009
Latest reply on Nov 4, 2009 by david_lalonde@d-cogit.ca

Summary

Possible Bug:  OnRecordRevert script trigger, + Exit Script with result 0

Description of the issue

There are a handful of script triggers in which the triggered script fires BEFORE the triggering event:  OnObjectKeystroke, OnObjectSave, OnObjectExit, OnRecordCommit, OnRecordRevert, OnLayoutKeystroke, OnModeExit, and LastWindowClose. Unlike the script triggers where the triggered script fires AFTER the triggering event has already occurred, these that fire BEFORE are supposed to allow the script to intercept the event itself:  if the script has an Exit Script [Result 0] script step,  the script should prevent the triggering event itself from actually taking place.  Example:  A layout with an OnLayoutKeystoke script trigger that fires off a script containing only the script steps Beep and Exit Script [Result 0] will intercept any keystrokes and will beep and the normative result of the keystroke will simply not occur. The bug, or inconsistency, is with OnRecordRevert.  Create a script with the same script steps and in Layout Mode set up the layout to perform that script OnRecordRevert, enabled in Browse Mode.   Put a regular text field on the layout.  To start with, set the layout to save record changes automatically.  Go into Browse Mode.  On an existing record, click into the text field and change the value; now choose Revert Record from the Records menu before committing the record with the change you made.  Confirm your intention to revert the record.  The script does fire (beep!) but it does revert the record despite the Exit Script [Result 0] script step!  Now go into Layout Mode again and switch the layout to NOT automatically save record changes.  Enter Browse Mode.  Modify your field again.  Click outside the field to prompt the dialog about committing the record (saving changes).  Click "Cancel", thereby indicating your desire to NOT save changes (hence REVERTING the record).  Again you get the script to fire (Beep!) but again, despite the Exit Script [Result 0] script step it cheerfully reverts the record anyhow. Now for the weird stuff.  Immediately click into the field again.  Modify the field, to some value that has never, to your knowledge, ever been in that field.  Click outside the record. With or without a script trigger, with the layout set to NOT automatically save the record it SHOULD ask you if you want to save your changes to this record, right?  But it doesn't, does it?  It simply accepts the change, just like a layout with the "Save record changes immediately" checkbox checked!   I have sat here and performed the same action and observed the alternating behavior and it is quite consistent:  change field, click outside field, "Save changes to this record?", click "Don't Save", hear the beep, record gets reverted, click into field, change field, click outside field, change is accepted w/o any dialog, click into field, change field, click outside field, "Save changes to this record?", etc etc etc.   At no point does the OnRecordRevert script kill off the attempt to revert the record. Under Layout Setup / Script Triggers, when OnRecordRevert is highlighted, the "Result" info at the bottom of the setup dialog screen clearly states "If the script returns true, the original event proceeds normally, otherwise the event is canceled". Apparently not. Addl Info: MacOS X 10.4.11, PowerPC; Fm Advanced 10.0v3

Outcomes