Home > Domino Tips > Developer > Formula > Revision history using formula language
Domino Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

FORMULA

Revision history using formula language


Rob Pinion
10.29.2001
Rating: -3.00- (out of 5)


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


This formula allows you to keep a revision history in a single computed field. Unlike most such revision trackers, it does not rely on the QuerySave event. The formula tests if the current user's name is in the most recent entry in the field. If so, only the date is updated so you don't get multiple entries for the same person if there is no intervening editor. The results display like this:

Joe Smith 10/29/2001 12:40:08 PM
George Bush 10/29/2001 12:40:46 PM
Rob Pinion 10/29/2001 12:50:15 PM
George Bush 10/29/2001 12:50:41 PM


Code

thisUser:=@Name([CN];@UserName);

REM "To use this function change the field name below from displayUpdater to your field name";
REM "The field should be Text, computed, allow multiple values, display separate entries with New Line";
thisfield:=displayUpdater;

REM "Assign all current lines in this field to a temporary variable";
existingLines:=thisfield;

REM "Each new line will have the user's name and the current date-time";
newLine:=thisUser+" "+@Text(@Now);

REM "Now compare to see if the current user is the most recent editor";
REM "Get the last entry since it contains the most recent editor";

REM "First get a count of the number of lines --- elements --- already there";
numLines:=@Elements(existingLines);

REM "If there's only one line assign it to lastEntry var, otherwise assign the last entry to lastEntry var";
lastEntry:=@If(numLines=1;existingLines;@Subset(existingLines;-1));

REM "Test whether the last line contains the name of the current user";
REM "Later we want to replace that line rather than adding a new line every time he saves the doc";
isSameUser:=@Contains(lastEntry;thisUser);

REM "Now get all lines but the last line";
allButLast:=@If(numLines=1;"";@Subset(existingLines;numLines-1));

REM "If the doc is being saved, then if this is same user return all but the last line followed by the new line";

REM "If this is not the same user, return everything preexisting plus a new line";

REM "If the doc is not being saved just show the contents of the field";

@If(@IsDocBeingSaved;@If(isSameUser;allButLast:newLine;thisfield:newLine);thisfield)


Rate this Tip
To rate tips, you must be a member of SearchDomino.com.
Register now to start rating these tips. Log in if you are already a member.


Submit a Tip




Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   



RELATED CONTENT
Formula
View hidden fields on Lotus Notes/Domino forms
Case-insensitive @Unique version combines fields on Lotus Notes forms
Provide rich-text formatting via the Profile document and Formula
Using Formula language code to sort Lotus Notes messages by subject
How to create dynamic JavaScript in Notes Domino without formulas
Formula language button manages Deny Access list searches
Retrieve Lotus Notes names from a nested group using @DBLookup
Create a computed Lotus Notes field to list Personal Address Book names
Show multiple Lotus Notes document fields in a single view column
How to send a document as a link in a Lotus Notes email

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary

DISCLAIMER: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.



Domino & Lotus Notes Security Solutions: Authentication, Antispam, Encryption and Antivirus
HomeTopicsITKnowledge ExchangeTipsAsk the ExpertsMultimediaWhite PapersDomino IT Downloads
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 1999 - 2009, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts