Adding a field for last modified by...

A place for users and developers of the Xataface to discuss and receive support.

Adding a field for last modified by...

Postby 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
 
Posts: 107
Joined: Mon Feb 13, 2012 9:03 pm

Re: Adding a field for last modified by...

Postby 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.
        );
    }
}
wisni1rr
 
Posts: 107
Joined: Mon Feb 13, 2012 9:03 pm

Re: Adding a field for last modified by...

Postby 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
ADobkin
 
Posts: 195
Joined: Mon Oct 22, 2007 7:31 pm
Location: Atlanta, GA, USA

Re: Adding a field for last modified by...

Postby wisni1rr » Thu Feb 23, 2012 6:03 pm

Thanks a lot!

Your link to a previous thread was most helpful.

Rich
wisni1rr
 
Posts: 107
Joined: Mon Feb 13, 2012 9:03 pm


Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 26 guests

Powered by Dataface
© 2005-2007 Steve Hannah All rights reserved