autopopulate column based on who's logged in? [SOLVED]

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

autopopulate column based on who's logged in? [SOLVED]

Postby cantlep » Wed Sep 01, 2010 4:14 am

Hi There,

is there anyway to automatically populate a field (i.e. a Username field) with the name of the user that's currently logged in?

What I'm after is that when a user logs in and creates a new record. Their username is auto added to a field (which I'll hide later on).

Thanks

Paul
Last edited by cantlep on Wed Sep 01, 2010 7:02 am, edited 1 time in total.
cantlep
 
Posts: 172
Joined: Fri Mar 05, 2010 2:14 am

Re: autopopulate column based on who's logged in?

Postby cantlep » Wed Sep 01, 2010 7:01 am

Sorted:

Found some old posts which helped:


Code: Select all
function beforeInsert(&$record){
    $auth =& Dataface_AuthenticationTool::getInstance();
    $user =& $auth->getLoggedInUsername();
    //$record->setValue('UserName', $user->val('UserName'));
    $record->SetValue('UserName', $user);
}

Did the trick :-)
cantlep
 
Posts: 172
Joined: Fri Mar 05, 2010 2:14 am


Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 31 guests

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