Edit history |
If there are fields in a textbase used to contain information about (a) who edited a record most recently, and (b) who edited it in the past, this script can be used in an edit form to automatically move the information from the first field to the second. This supports maintaining a history of who has edited a record. |
Script Language: JavaScript | For use with: DB/TextWorks | Requires at least version 4.0 |
// The box having the script name "lastedited" contains
// the field to identify who is editing the record.
// The box "edithistory" contains the history of who
// has previously edited the record.
var curBoxName = "lastedited";
var histBoxName = "edithistory";
function onRecordOpen()
{
var curBox; // curBoxName box object
var histBox; // histBoxName box object
var curBoxCont; // previous contents of curBox
var histBoxCont; // previous contents of histBox
var es; // entry separator
var newHist; // new contents of histBoxName
// check for existence of boxes curBoxName and histBoxName,
// returning if they do not exist (or have not been given
// appropriate script names)
curBox = Form.boxes(curBoxName);
histBox = Form.boxes(histBoxName);
if (!curBox)
return;
if (!histBox)
return;
// put the previous contents of each box into a variable
curBoxCont = curBox.content;
histBoxCont = histBox.content;
// get the entry separator
es = Application.entrySeparator;
// add previous curBox contents to histBox contents and empty curBoxName
if (histBoxCont == "")
newHist = curBoxCont;
else
newHist = curBoxCont + es + histBoxCont;
histBox.content = newHist;
curBox.content = "";
} |
Notes: To ensure that the necessary information is supplied every time the record is edited, use validation to make the "most recently edited" field required. Also consider making it a date field and/or using mask validation to ensure that the date and editor's initials are captured. | Submitted by Inmagic Staff on 11/30/2000 |