Adding a field for last modified by…

Archived from the Xataface Users forum.

wisni1rr — Thu Feb 23, 2012 1:03 pm

This should be an easy one.

How can I make a field in a table auto update with the current logged in user after a record has been created/modified?

Thanks again and again and again!!!


wisni1rr — Thu Feb 23, 2012 1:20 pm

I think I am looking for something like this…

Code: Select all
class tables_GENERAL {     function beforeSave($record){         $record->setValue('LastModifiedBy',      //* I need the syntax to replace 'LastModifiedBy' with the current logged in username.         );     } }

ADobkin — Thu Feb 23, 2012 1:24 pm

I use the following:

Code: Select all
function beforeInsert(&$record) {     // Track creator     $user =& getUser();     $uid = getUserIDVal($user);     if ( $uid ) {         $record->setValue('creator', $uid);         $record->setValue('modifier', $uid);     } }
Code: Select all
function beforeUpdate(&$record) {     // Track modifier     $user =& getUser();     $uid = getUserIDVal($user);     if ( $uid ) $record->setValue('modifier', $uid); }

For more details, refer to this post:

Record Tracking


wisni1rr — Thu Feb 23, 2012 6:03 pm

Thanks a lot!

Your link to a previous thread was most helpful.

Rich