#2 is bad in your use case, but good for some people that aren't trying to deal with "transactions" for their database.
- The layout has only two buttons available: Save and Cancel.
- Save Record Changes Automatically is Enabled
Why? The very nature of having a "save" button indicated that you should turn OFF the auto-save changes checkbox in the layout settings. Have you tried unchecking that to see if it changes the #2 action?
Why is Save Changes Automatically enabled for this layout?
If Save Record Changes Automatically is off, then I find that if the user clicks out of a field, they get the FileMaker "Save Changes to this Record" dialog, which is what I'm trying to block.
I wonder if there's a second event I need to be catching in addition to OnRecordCommit ? Perhaps OnLayoutExit or something?
You need a couple triggers to suppress the default filemaker dialog.
And then adding to your save button script:
Mike, I already have the variable logic like you suggest. That's not the problem.
The problem seems to be that when Save Record Changes Automatically is disabled, then I'm getting the "Save Changes to this Record" dialog and OnRecordCommit event never triggers so there's no way for me to block it.
The OnRecordCommit is a pre-trigger, meaning that it runs before the save action takes place.
Can you post copies of your OnRecordLoad and OnRecordCommit scripts so we can review?
Per this discussion, How to get rid of "Save changes to this record" the OnRecordCommit will only fire as a pre-trigger if Save Record Changes Automatically is ON. Otherwise it fires post-commit.
This is sensible in general, but causes problems in WebDirect because as I mentioned, if a user just closes the Web Browser, then the record is Committed.
I've tried catching the OnLayoutExit event but it seems to be even later.
I've got a couple of ideas:
- The old "make a gigantic button in the background" trick to prevent mouse clicks from exiting the record.
- Additional error checking by script: I could make a new field "timestampThatThisRecordWasSaved" which only gets set by my Save button. If a record exists without that timeStamp then I can assume it's bogus.
Neither is very attractive, however.