Using Lotusscript To Mark Recent Documents For Display On The Web

Author: Tripp W Black

Created: 01/12/2002 at 06:51 PM

 

Category:
Notes Developer Tips
Agents, LotusScript

USING LOTUSSCRIPT TO MARK RECENT DOCUMENTS FOR DISPLAY ON THE WEB
By Dan Velasco, Senior Technical Editor (dvelasco@dominopower.com)

A while back, I did a tip about different ways to show recent documents on the
Web, such as using embedded views with the count parameter or using the show
single category feature in R5 to show documents from a specific date or month.
The problem that you often run into, however, is that sometimes you want to
display links to recent documents from multiple views or from different
databases on a single page or form. In this situation, the two solutions above
don't work well.

Instead, what you can do is to create a simple scheduled agent in your database
to mark the most recent documents, and then use an @DbColumn formula to retrieve
those documents for display on a page/form. Below is sample code that you can
modify to mark the most recent documents in your database.

Sub Initialize

'--DIM THE VARIABLES
Dim session As New NotesSession
Dim currentDB As NotesDatabase
Dim dateView As NotesView
Dim recentView As NotesView
Dim dateDoc As NotesDocument
Dim recentDoc As NotesDocument

'--SET THE VARIABLES
Set currentDB = session.CurrentDatabase
'--CUSTOMIZE CODE WITH YOUR VIEW NAMES
Set dateView = currentDB.GetView("LookupByDateView")
Set recentView = currentDB.GetView("LookupByRecentView")

'--UNMARK THE MARKED DOCUMENTS
Set recentDoc = recentView.GetFirstDocument

Do Until recentDoc Is Nothing
'--GET A HANDLE ON THE NEXT RECENT DOCUMENT BEFORE YOU CHANGE THIS ONE
Dim nextRecentDoc As NotesDocument
Set nextRecentDoc = recentView.GetNextDocument(recentDoc)

recentDoc.Recent = ""
Call recentDoc.Save(True, True)
Set recentDoc = nextRecentDoc
Loop

'--MARK THE THREE MOST RECENT DOCS
Set dateDoc = dateView.GetFirstDocument

For i = 0 To 4
dateDoc.Recent = "Yes"
Call dateDoc.Save(True, True)
Set dateDoc = dateView.GetNextDocument(dateDoc)
i = i + 1
Next

End Sub

A few quick notes:

* Sort both views by date, descending.
* ou can put the @DbColumn lookup code in a computed field or a computed text
item.
* You can use @Implode to put breaks in the lookup result if you're using
Pass-Thru HTML.

Here is a sample lookup formula:

lookup := @DbColumn("":"NoCache"; "PUTREPLICAIDHERE" ; "LookupByRecentView"; 2);
@If ( @IsError ( lookup ) ; "Data Not Loaded" ; @Implode ( lookup ; "<br>" ) )


previous page