Nav view search

Navigation

Search

The Exchange

The place to download pre-configured tickets, code snippets, and solutions

Back

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.

Note: This solution is optimized for Virtual Ticket Developer.

If you are using Workgroups DaVinci and are planning to use a Toolbox snippet not marked as DaVinci-compatible, please check with Support for possible compatibility issues before using.

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

Last Modified:

2014-11-26

by

Chris True