Thanks in advance,
Steve
Sent via Deja.com http://www.deja.com/
Before you buy.
TITLE: Simulating a dynamic view using folders
Author: Shawn Conlin, Retail Store Systems
I have seen a number of situations where it would be
great to have a user answer a few prompted questions
and have the view display the corresponding documents.
Views do not handle dynamics very well, but I found
that folders work wonderfully. I recommend setting the
folder up as Shared, private on first use, but it must be
stored in the server copy. You can then setup 2 scripts
one that empties the folder and one that populates it.
You could also delete the view instead of clearing it.
When I set it up, I established the scripts as agents
that run from buttons in the folder, this allows the
user to perform multiple searches without having to
close and open the folder. Below I have included
sample script and @functions for the button and agents.
The folder can be categorized or display the docs
any way that is desired. I coded the Empty agent
to remove docs from the bottom up, as I have
found this method to work better when working
from categorized views.
'Programming behind button to run the scripts
user := @Name([CN];@PickList([Name]: [Single]));
rdate := @Prompt([OKCANCELEDIT];"Enter Start Date";"Enter start date for the
report:" + @Char(13) + "The database contains information from the past 60
days only.";"");
@Environment("TRName"; user);
@Environment("TRDate"; rdate);
@PostedCommand([ToolsRunMacro]; "(EmptyFolder)");
@PostedCommand([ToolsRunMacro]; "(CreateTimeReport)")
'Add entries to folder agent
Sub Initialize
Dim W As New NotesUIWorkspace
Dim S As New NotesSession
Dim CurDB As NotesDatabase
Dim LView As NotesView
Dim TFolder As NotesView
Dim DColl As NotesDocumentCollection
Dim Doc As NotesDocument
Dim TRDate As String
Dim TRName As String
Set CurDB = S.CurrentDatabase
Set LView = CurDB.GetView("(TimeLookup)")
Set TFolder = CurDB.GetView("Time Report")
TRName = S.GetEnvironmentString("TRName")
TRDate = S.GetEnvironmentString("TRDate")
Set DColl = LView.GetAllDocumentsByKey(TRName, True)
If DColl.Count > 0 Then
Set Doc = DColl.GetFirstDocument
While Not(Doc Is Nothing)
If Datevalue(Doc.EntryDate(0)) >= Datevalue(TRDate) Then
Call Doc.PutInFolder("Time Report")
End If
Set Doc = DColl.GetNextDocument(Doc)
Wend
End If
Call TFolder.Refresh
End Sub
'Empty Folder Agent
Sub Initialize
Dim S As New NotesSession
Dim CurDB As NotesDatabase
Dim TFolder As NotesView
Dim Doc As NotesDocument
Dim TDoc As NotesDocument
Set CurDB = S.CurrentDatabase
Set TFolder = CurDB.GetView("Time Report")
Set Doc = TFolder.GetLastDocument
While Not(Doc Is Nothing)
Set TDoc = Doc
Set Doc = TFolder.GetPrevDocument(Doc)
Call TDoc.RemoveFromFolder("Time Report")
Wend
Call TFolder.Refresh
End Sub
<powe...@my-deja.com> wrote in message news:87seas$pr0$1...@nnrp1.deja.com...