Recording the Time and Date When a Record is Saved
Use a Global MetaScript to record the current server time and date whenever a record is saved.
Introduction
By using an event listener in a form's Global MetaScript, the current server time and date can be recorded whenever the record is saved.
By recording the time and date of the server, you can eliminate any disparity between individual client computer clocks and that introduced by client computers in different time zones.
Note that this snippet is part of a series that explores different ways of recording time and dates. See Toolbox Snippet Time and Date Series Snippet Index for other related methods.
Description
The following Global MetaScript can be used in a form to capture the server time and date whenever a record is saved.
//@version "2.0" Form.addEventListener("saveObject", RecordSaveTime); function RecordSaveTime( aEvent ) { if(Form.objectState == "existing") { SetField("TS_921_SavedTime", ServerTime()); SetField("TS_921_SavedDate", ServerDate()); } } //"TS_921_SavedTime" and "TS_921_SavedDate above should be changed to the names of the fields you will use to store the recorded time and date.
Resources
- Download and install a sample form illustrating this Toolbox Snippet (see below)
- Time and Date Series Snippet Index