This topic is locked

Tracking Table

12/18/2008 2:02:52 AM
ASPRunnerPro General questions
G
guroos author

The client wants to track changes made to a table showing who, when, what changes were made.

I know 'who' can be done by session("UserID") and 'when' = now() but how would I place only the changed fields (there are 30 fields on the form) into a tracking table.
I saw some code in a previous topic that I have tried for 2 days to make work but I am afraid the circumstance was not quite near enough for me to adapt it.

J
Jane 12/18/2008

Hi,
compare old and new values in the event and save changed fields only.

Old values are in the oldvalues dictionary, new values are in the dict dictionary.

Here is a sample:

Dim dkeys

message =""
dkeys = dict.keys

For n = 0 To dict.Count-1

if dict(dkeys(n))<>oldvalues(dkeys(n)) then

message = message & dkeys(n) & " is changed. Old value: " & oldvalues(dkeys(n)) & ", new value: " & dict(dkeys(n)) & "
"

end if

Next
Response.write message

G
guroos author 12/18/2008

Hi,

compare old and new values in the event and save changed fields only.

Old values are in the oldvalues dictionary, new values are in the dict dictionary.

Here is a sample:


Wow, Jane...thanks very much...works perfectly. For the information of anyone else I added the above code to the 'edit page' 'before record updated' and the following code to the 'edit page' 'after record updated':
dal.t_Tracking.UserID=SESSION("UserID")

dal.t_Tracking.CompanyID=dict("CompanyID")

dal.t_Tracking.TrackingInfo=message

dal.t_Tracking.DateChangeMade=now()

dal.t_Tracking.Add()

L
lbragg 2/1/2009

I have been trying to figure out how to use the event code supplied with 6.0 build 766 in Edit page before record updated called "Save old data record in another table".

I can not get the right syntax and keep getting an error "424 object required". I'm sure I just am missing something but there isn't any documentation on how to use

the dal feature in asprunner. Below is the code I have thus far and I probably have something completely wrong. Anyone have any ideas what?
Table being edited is project

Table being updated by event is hist_project

Fields being updated by event is project_id, project_customer, project_descript, project_date, project_due, project_notes, project_csr, project_userid, project_notified, and project_mod_by.
Here is the code I changed in BeforeRecordUpdated:
set rsFields = dal.Table(strTableName).Query(where,"")

if not rsFields.eof then

dal.hist_project.project_id=rsFields("project_id")

dal.hist_project.project_customer=rsFields("project_customer")

dal.hist_project.project_descript=rsFields("project_descript")

dal.hist_project.project_date=rsFields("project_date")

dal.hist_project.project_due=rsFields("project_due")

dal.hist_project.project_notes=rsFields("project_notes")

dal.hist_project.project_csr=rsFields("project_csr")

dal.hist_project.project_userid=rsFields("project_userid")

dal.hist_project.project_notified=rsFields("project_notified")

dal.hist_project.project_mod_by=rsFields("project_mod_by")

dal.hist_porject.Add()

end if

rsFields.close: set rsFielgs=nothing
BeforeEdit= True

J
Jane 2/3/2009

Hi,
see my changes below:

set rsFields = dal.project.Query(where,"")

if not rsFields.eof then

dal.hist_project.project_id=rsFields("project_id")

dal.hist_project.project_customer=rsFields("project_customer")

dal.hist_project.project_descript=rsFields("project_descript")

dal.hist_project.project_date=rsFields("project_date")

dal.hist_project.project_due=rsFields("project_due")

dal.hist_project.project_notes=rsFields("project_notes")

dal.hist_project.project_csr=rsFields("project_csr")

dal.hist_project.project_userid=rsFields("project_userid")

dal.hist_project.project_notified=rsFields("project_notified")

dal.hist_project.project_mod_by=rsFields("project_mod_by")

dal.hist_porject.Add()

end if

rsFields.close: set rsFielgs=nothing