Manage Learn to apply best practices and optimize your operations.

Last Modified User/Date Audit Trail, Only 1 Entry Per User In A Document Session

Ever try to leave an audit trail of who modified a document when? Notice that
4.x (is it fixed in 5?) updates it?s $Revisions field every time someone
requests a save, even if the save gets canceled because of a validation or some
other error???? The QuerySave event happens the same way and by the time you
get to the QueryClose event, you can?t update fields anymore!! Or if a user
makes a lot of changes in one session, you really don?t need their name and
date every time, just once.

I came up with something, not perfect, but not bad! I use a computed field to
gather the date and name for each save (but replacing everytime until closed).
So when the document is finally closed, only the last save time for the user
will appear. The next time the document goes into edit mode, the code (for
postopen or postmodechange) will take the info on the last modification and
populate it in the changetrail filed.

Uses 4 fields, must be in this order on form!:

LastModified - Text; Computed; Hidden always; value =
FIELD LastModified := LastModified;
@If( @IsDocBeingSaved ; @Text(@Now) + " " + @Name([CN];@UserName);LastModified)

cd_LastModified - Text; Computed; value = LastModified


ChangeTrail - Text; Editible; Multi-Valued; Hidden always

cd_ChangeTrail - Text; Computed; Mulit-Valued; Options-Display Seperate Values
With NEW LINE;
value = ChangeTrail

Form's PostOpen Event AND PostModeChange Event::
FIELD LastModified := LastModified;
FIELD ChangeTrail := ChangeTrail;
@If(LastModified != "" & @IsDocBeingEdited;

@Do(@SetField("ChangeTrail";LastModified:ChangeTrail);@SetField("LastModified";"
"));
@Success)

Or, if you already have script in either one of these events (like I do in some
forms), this script will perform the same thing (remember Source is declared in
both events):
Dim LastMod as String
Dim ChangeTrail as String
If Source.EditMode Then
LastMod = Source.FieldGetText("LastModified")
If LastMod = "" Then
'nothing to do
Exit Sub
Else
ChangeTrail =Source.FieldGetText("ChangeTrail")
Call Source.FieldSetText("ChangeTrail",LastMod + "," + ChangeTrail)
End If
End If
Uses 4 fields, must be in this order on form!:

LastModified - Text; Computed; Hidden always; value =
FIELD LastModified := LastModified;
@If( @IsDocBeingSaved ; @Text(@Now) + " " + @Name([CN];@UserName);LastModified)

cd_LastModified - Text; Computed; value = LastModified


ChangeTrail - Text; Editible; Multi-Valued; Hidden always

cd_ChangeTrail - Text; Computed; Mulit-Valued; Options-Display Seperate Values
With NEW LINE;
value = ChangeTrail

Form's PostOpen Event AND PostModeChange Event::
FIELD LastModified := LastModified;
FIELD ChangeTrail := ChangeTrail;
@If(LastModified != "" & @IsDocBeingEdited;

@Do(@SetField("ChangeTrail";LastModified:ChangeTrail);@SetField("LastModified";"
"));
@Success)

Or, if you already have script in either one of these events (like I do in some
forms), this script will perform the same thing (remember Source is declared in
both events):
Dim LastMod as String
Dim ChangeTrail as String
If Source.EditMode Then
LastMod = Source.FieldGetText("LastModified")
If LastMod = "" Then
'nothing to do
Exit Sub
Else
ChangeTrail =Source.FieldGetText("ChangeTrail")
Call Source.FieldSetText("ChangeTrail",LastMod + "," + ChangeTrail)
End If
End If

Dig Deeper on Domino Resources - Part 7

Join the conversation

1 comment

Send me notifications when other members comment.

Please create a username to comment.

Hi, may I know the "ChangeTrail" is for what?
Cancel

-ADS BY GOOGLE

SearchWindowsServer

Search400

  • iSeries tutorials

    Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...

SearchDataCenter

SearchContentManagement

Close