|
|
|
|
|
|
|
|
|
|
|
|
|
|
A flexible approach to keeping a history of recent edits (continued)
The meat of the formula is identical for all four list fields, so if you change one, you should copy the change over to the other three as well. This part of the formula builds a list for each possible scenario--one for Append and one for Replace. If the sliding window of history rows is exceeded, it also removes the oldest row. Only one list is actually used, but computing both up front makes the formula easy to read.
DEFAULT fEHMax := 5;
rlist := @If(
n<2;
newval;
newval : @Subset( list; -(n-1) )
);
alist := @If(
n < 1;
newval;
n >= fEHMax;
newval : @Subset(list; fEHMax-1);
newval : list
);
val := @If(
@IsNewDoc;
"";
@IsDocBeingSaved;
@If(
fdEHIntervalControl = "Replace";
rlist ;
alist
);
list
);
@If ( @IsError(val); ValIfError; val)
|
That's about all there is to it. You may be surprised that up to this point the subform hasn't used any LotusScript, especially since some of these field formulas are pretty involved and tend to duplicate each other. I chose to stick with formula language instead of using LotusScript (in the QuerySave event) for two main reasons. In the first place, formula language is more "native" to Notes and therefore works better across both clients (Notes and Web). Secondly, all the central fields in this tool are list fields, and formula language handles lists much more intuitively than LotusScript.
The Descriptions feature, however, does use LotusScript for the Notes interface. If the feature is enabled, every editor (except the original creator) is prompted on QuerySave to describe the edits being saved. If cancelled or left blank, the save is then blocked. If a value is entered, it's placed in a hidden field named fEHDescription, which is then used as the new value for the fEHDescriptions field.
Sub Querysave(Source As Notesuidocument, Continue As Variant)
Dim doc As NotesDocument, strTemp As String, item As NotesItem
Set doc = Source.Document
If (doc.fEHPrompt(0) = "1") And (doc.Form(0) <> "") Then
strTemp = Inputbox$ ( "Please enter a brief description of your edits." , "Editor History", doc.fEHDescription(0))
doc.fEHDescription = strTemp 'Create or update the fEHDescription field
If strTemp = "" Then
Continue = False
End If
End Sub
|
At this point, the issue of column widths becomes particularly important, since we have little control over how long an editor's description will be. To make sure that no lines wrap while preserving all the entered text, I've hidden the real fEHDescriptions field and substituted a truncated display field in the viewable table. But of course, the users will need some sort of access to the full descriptions, so I've added a formula popup to display the full descriptions when the column title is clicked:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- Advertisement --
Learn Notes and Domino 8 at your place and pace!
Learn Notes and Domino in your office and/or home! TLCC's highly acclaimed distance learning courses for users, developers, and admins will enhance your career and your resume.
The many included activities and demos will make you a pro! Expert instructor help is a click away.
Click here to try a FREE demo course!! |
-- Advertisement --
Mark your calendar for in-depth Lotus training, May 12-14, Boston
Join experts and peers May 12-14 in Boston for educational and networking events that deliver real-world Lotus training so you can increase productivity and efficiency in your company, advance your skills, and squeeze the most from your current environment. One registration gets you into THE VIEW's Admin2010 and Lotus Developer2010.
Register by April 10 to save $200. |
|
|
|
|
|
|
|
|
|
|