This topic is locked

Automatically Updating User Details / Date Time

1/3/2009 12:48:22 PM
PHPRunner General questions
W
wypman author

I have a user table with userID and UserName in. I have another table containing records that I want to automatically update with the logged in person adding the record or updating it.
I've tried using a read only text field with the default value set to $_SESSION["UserID"] and the datefield, again a Readonly text field, default value set to now().
The tables are linked on the datasource tables view - but I get strange results.
I basically have 4 fields I want to update automatically:
On adding a record I want to update

Submitted By

Updated by


with the current logged in person and Sudmitted Date and Updated Date to be the current time.
When the record is edited I only want the Updated By / Updated Date to change.
I can't get it working, should I put the data in code and how can I get it to display then name instead on a number. Sometimes it displays the name in one view but not in another..
Any suggestions greatfully received.

hichem 1/3/2009

I have a user table with userID and UserName in. I have another table containing records that I want to automatically update with the logged in person adding the record or updating it.

I've tried using a read only text field with the default value set to $_SESSION["UserID"] and the datefield, again a Readonly text field, default value set to now().
The tables are linked on the datasource tables view - but I get strange results.
I basically have 4 fields I want to update automatically:
On adding a record I want to update

Submitted By

Updated by


with the current logged in person and Sudmitted Date and Updated Date to be the current time.
When the record is edited I only want the Updated By / Updated Date to change.
I can't get it working, should I put the data in code and how can I get it to display then name instead on a number. Sometimes it displays the name in one view but not in another..
Any suggestions greatfully received.


I had a similar question and may be it can be logged as a feature request to have it built into the software. Ideally we would want an automated logging or automated audit trail for all changes (including the possibility to track what each user has viewed).

J
Jane 1/5/2009

Hi,
use Before record added and Before record updated events to update these fields.

Here is a sample:

$values["Submitted By"] = $_SESSION["UserID"];

$values["Sudmitted Date"] = now();



Username of current user is stored in the $_SESSION["UserID"] variable.

W
wypman author 1/30/2009

Hi,

use Before record added and Before record updated events to update these fields.

Here is a sample:
Username of current user is stored in the $_SESSION["UserID"] variable.


Missed this reply. Thanks Jane I'll give it a go.