AnsweredAssumed Answered

Script Trigger Needed "Upon Record Exit"

Question asked by JCrawford on Sep 10, 2013
Latest reply on Sep 10, 2013 by philmodjunk


Script Trigger Needed "Upon Record Exit"


     I need to document the Account Name and Timestamp when an employee loads a record, and another timestamp when they exit that same record. An elapsed time documents how long the employee had that confidential record open for viewing.

     The purpose is to document both authorized and unauthorized access to confidential records. All employees have access to all records as they may have a need to know, but if they access a record they shouldn't have seen, then the database must document that access. It isn't necessary to modify the record, just to look at it. The employees, in turn, worried about discipline actions, asked for another feature that tracked how long they were on that record. If they were accidentally on a wrong record for a few seconds, the discipline should not be as severe as being on the wrong record for 30 minutes.

     I am using a relationship of two tables Client::Accessed By, with a portal on the client record. Two script triggers document when the user loaded the record (Time In) and when they exit the record (Time Out).

     The Time In script runs on "Upon Record Load" and works fine. It goes to the bottom of the portal, creates a new record, and sorts the new record to the top.

     The Time Out script would work if there were a script trigger that ran "Upon Record Exit," but that command doesn't exist. It goes to the top record and enters a value in the Time Out field.

     I tried "Upon Record Commit" but this command requires some record modification to work properly. If the record isn't modified, it will alter the last access record upon record load, before the Time In script creates a new access record.

     A snapshot is attached which shows the problem. If you look closely, you will see the Time In value on the top record is equal to the Time Out value on the second record. This pattern is repeated throughout the set of records. Every time the record loads, the Time Out script (based upon On Record Commit) runs first, changing the value of the top most Time Out record. Then the Upon Record Load script runs, creating a new top most record.

     I don't want the Time Out field to change upon Record Load or Record Commit. I want it to change upon Record Exit.

     Is there a work around for the missing command "Upon Record Exit"?