Best Practice for LastModifiedUser and LastModifiedDate fields in a BO
 
Home My Account Forum Try It! Buy It!
About Contact Us Site Map
StrataFrame Forum
Home      Members   Calendar   Who's On
Welcome Guest ( Login | Register )
      



Best Practice for LastModifiedUser and...Expand / Collapse
Author
Message
Posted 05/06/2008 10:20:35 AM
StrataFrame User

StrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame User

Group: StrataFrame Users
Last Login: Yesterday @ 9:46:15 PM
Posts: 288, Visits: 1,135
Hi,

For some tables it is very useful to have a fields that will tell the user when was the record changed and by who. 

  • Is there anything in SF logic to auto update this kind of fields?
  • If these fields should be updated manually what would be the correct event to use to have these fields updated?

Thansk!

Edhy Rijo
Progytech (Computer Consultants)
Post #16179
Posted 05/06/2008 12:38:49 PM
StrataFrame User

StrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame User

Group: StrataFrame Users
Last Login: Yesterday @ 3:00:39 PM
Posts: 244, Visits: 816
Hey Edhy,

There are probably several ways to do this.  My approach is to create four fields on each table that I want to track this kind of activity: createby, createdate, editdby, editdate.  I retrieve the UserPK from the SF users table for the current user, then in the BO I use two built-in methods:  SetDefaultValues() and BeforeSave().  In the SetDefaultValues() I set the create information.  In the BeforeSave() I set the edit information.  I never have to think about it after that.

Hope that gives you some direction,
Bill

Post #16182
Posted 05/06/2008 12:56:16 PM
StrataFrame User

StrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame User

Group: StrataFrame Users
Last Login: Yesterday @ 9:46:15 PM
Posts: 288, Visits: 1,135
Bill Cunnien (05/06/2008)
In the SetDefaultValues() I set the create information.  In the BeforeSave() I set the edit information.  I never have to think about it after that.
Bill

Hi Bill,

Thanks for the information it does make sense, only that having to do that manually for all BO may be a bit of work  I have a couple of VFP project which will be re-created in SF and I need to automate process like this as much as possible.

Edhy Rijo
Progytech (Computer Consultants)
Post #16183
Posted 05/06/2008 1:01:27 PM
StrataFrame User

StrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame User

Group: StrataFrame Users
Last Login: Yesterday @ 3:00:39 PM
Posts: 244, Visits: 816
You could create a BaseBO from which any BO could inherit that will need this kind of tracking.  For me, I am running into variations in the column names, so I have to address the issue on a BO by BO basis anyway.  It is relatively easy to setup...just one simple item in the mental checklist for creating a BO.  I could see where a BaseBO would be beneficial in a large, consistently named environment.
Post #16186
Posted 05/06/2008 1:08:27 PM
StrataFrame User

StrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame User

Group: StrataFrame Users
Last Login: Yesterday @ 9:46:15 PM
Posts: 288, Visits: 1,135
Thanks again Bill, a base BO makes sense, will try that path.

Edhy Rijo
Progytech (Computer Consultants)
Post #16187
Posted 05/06/2008 1:28:23 PM


StrataFrame Developer

StrataFrame Developer

Group: StrataFrame Developers
Last Login: Yesterday @ 3:24:00 PM
Posts: 3,733, Visits: 3,926
We actually take a similar approach within our medical application on the CreatedBy and CreatedAt fields.  As for the editing fields, we have started implementing some auditing features on certain tables so that you can determine what was changed by the user.  Just know which user and the time is not generally enough...the next question is always, "what did they change?"

There are actually a number of ways to go about this...you can use event hooks that you can manually implement on your base BO (i.e. Beforesave, etc.).  We also have some classes that are actually in the framework to audit a BO record...though I will not tell you about all of that until we have the viewer ready

We are implementing auditing several different ways within our medical application because some things are more sensitive than others...but the more auditing that you add, the slower things will become.  So this is one of those things that has to be used with caution.

Post #16191
Posted 05/06/2008 1:39:19 PM
StrataFrame User

StrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame User

Group: StrataFrame Users
Last Login: Yesterday @ 9:46:15 PM
Posts: 288, Visits: 1,135
We also have some classes that are actually in the framework to audit a BO record...though I will not tell you about all of that until we have the viewer ready

I did notice the AudiDataChanges and NeverAuditDataChanges properties in the BO but could not find any information about those in the help or the forums.  For now I don't need any viewer because these fields will be shown in a StatusBar for some forms only.  So if there is something in the framework now I could use for this specific situation then I would like to, if not then I will have to go with the BO base class approach.

I agree that Audit Trail is a complicated stuff and in my VFP projects I used it in just 2 or 3 projects and in some specific forms to avoid the slow down of the DBF tables with memo fields.

Edhy Rijo
Progytech (Computer Consultants)
Post #16195
Posted 05/06/2008 2:02:41 PM


StrataFrame Developer

StrataFrame Developer

Group: StrataFrame Developers
Last Login: Yesterday @ 3:24:00 PM
Posts: 3,733, Visits: 3,926
SF auditing requires that you have RBS.  All of this is done through the security side so that you can turn on auditing for one user and not another, etc.

But if you set the AuditDataChanges property to True, and then the current user supports auditing (which you cannot override at the moment), and you have your app setup with security...AND you have the SFSAuditDataChanges, SFSAuditDataFields, and SFSAuditEvents deployed to the same database as your other RBS tables, then it should work.

You can also call the audit methods directly by using the Auditor class in security:

MicroFour.StrataFrame.Security.Auditor.InsertAuditEvent("1234", "User logged in.", New Byte() {})
MicroFour.StrataFrame.Security.Auditor.InsertAuditEvent("1234", "Business object state prior to save...", SerializedByteArrayOfBO)

You can store anything that you want in the Byte Array parm.  We will have a delegate that you set in the viewer that gets called to determine how to show or view that data.  This approach allows you to store literally anything you want as additional data within the audit record.

Post #16202
« Prev Topic | Next Topic »


Reading This TopicExpand / Collapse
Active Users: 0 (0 guests, 0 members, 0 anonymous members)
No members currently viewing this topic.
Forum Moderators: Ben Chase, Trent L. Taylor, Steve L. Taylor