Manage Learn to apply best practices and optimize your operations.

How to add an audit trail to Lotus Notes documents using Formula

In many Notes/Domino applications, you need to track critical field values any time a document is modified and saved. In this tip, SearchDomino.com member Mohammed Misbahuddin explains step-by-step how you can easily add audit trails using Formula code.

VIEW MEMBER FEEDACK TO THIS TIP

In many Notes/Domino applications, you need to track critical field values any time a document is modified and saved. Fortunately, you can add these audit trails with a relatively small amount of Formula code.

Subsequently, an audit trail report can be generated with each event on a separate line, starting from the creation of the Lotus Notes document. For example, if you want to have an audit trail for the User Name, Date Time and Workflow Status fields, here's what you would need to do:

  1. Add these extra computed text fields that are hidden with default Formula as follows:
    ATUserName Default formula :  
    @If(!@IsNewDoc; ATUserName + @NewLine + @Name
    ([CN];@UserName ); ATUserName ) 
    ATDateTime Default formula : @If(!@IsNewDoc; 
    ATDateTime + @NewLine + @Text(@Now )); ATDateTime) 
    ATWorkflowStatus Default formula : @If(!@IsNewDoc; 
    ATWorkflowStatus+ @NewLine + WorkflowStatus; ATWorkflowStatus)

  2. Create a hidden view, or AuditTrail, with Request ID as the first column; then the audit trail fields as the subsequent columns.

  3. Create an Audit Trail Report form with first editable field on the top as Request ID and a table with two rows and three columns. In first row, put the column names as User Name, Date Time and Workflow Status. In the second row, in each column, add one of the three computed for display text fields as: ATRUserName, ATRDateTime and ATRWorkflowStatus.

    Note: The field values should not be too long otherwise the lineup of each row will be disturbed. The field values should not exceed the column width of the table.

  4. Finally, add an action button on the Audit Trail Report form with the following Formula code:
    @If( Request_ID = "";""; @Do(@SetField
    ("ATRUserName";@DbLookup("Notes":"Nocashe";"";"
    (AuditTrail)"; Request_ID;2)); @SetField("ATRDateTime";
    @DbLookup("Notes":"Nocache";"";"(AuditTrail)"; Request_ID;3)); 
    @SetField("ATRWorkflowStatus";@DbLookup
    ("Notes":"Nocashe";"";"(AuditTrail)"; Request_ID;4))));

MEMBER FEEDBACK TO THIS TIP

You can also modify the default formula in step 1 of this tip, so that it does not refresh the formula until it is saved.

ATUserName Default formula :  
@If(!@IsNewDoc & @IsDocBeingSaved; ATUserName + @NewLine + @Name
([CN];@UserName ); ATUserName ) 
ATDateTime Default formula : @If(!@IsNewDoc & @IsDocBeingSaved; 
ATDateTime + @NewLine + @Text(@Now )); ATDateTime) 
ATWorkflowStatus Default formula : @If(!@IsNewDoc & @IsDocBeingSaved; 
ATWorkflowStatus+ @NewLine + WorkflowStatus; ATWorkflowStatus)

—Mohammed Mishabuddin, tip author

Do you have comments on this tip? Let us know.

Related information from SearchDomino.com:

  • Formula Language Learning Guide
  • Reference Center: Formula Language tips and resources

    This tip was submitted to the SearchDomino.com tip library by member Mohammed Misbahuddin. Please let others know how useful it is via the rating scale below. Do you have a useful Lotus Notes, Domino, Workplace or WebSphere tip or code snippet to share? Submit it to our monthly tip contest and you could win a prize.

  • This was last published in April 2006

    Dig Deeper on Lotus Notes Domino Formula Language

    Start the conversation

    Send me notifications when other members comment.

    Please create a username to comment.

    -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