Many Lotus Notes Domino organizations find it useful to parameterize a Lotus Notes view selection to limit its results. The reasons for this are generally twofold:
Only a portion of all data contained in a view is needed.
Exporting to other Notes/Domino applications is difficult due to the volume.
Although there's a great need to use parameters to limit the results of the Lotus Notes view, not much has been done because the view is maintained on the server side. This tip explains the methods that one company used to filter Lotus Notes view selections and gives a few real-world examples.
Note: You must have Designer access to accomplish this. Also, make sure that "Create shared folders and views" is enabled on your access control list.
First, create an action button with the following script:
Код:
Dim Session As New NotesSession
Dim uiworkspace As New NotesUIWorkspace
Dim uiview As NotesUIView
Dim view As NotesView
Dim NewViewFormula As String
NewViewFormula = |SELECT Form = "Form Name Here" & FieldName = "Value"|
Set uiview = uiw.CurrentView
Set view = uiview.View
view.SelectionFormula = NewViewFormula
Call uiworkspace.ViewRebuild
Following is an example of the above code in action. The following LotusScript will modify the "view" selection formula to display all documents with the department name specified as "Marketing."
Код:
Dim Session As New NotesSession
Dim uiworkspace As New NotesUIWorkspace
Dim uiview As NotesUIView
Dim view As NotesView
Dim NewViewFormula As String
NewViewFormula = |SELECT Form = "Form Name Here" & DepartmentName = "Marketing"|
Set uiview = uiw.CurrentView
Set view = uiview.View
view.SelectionFormula = NewViewFormula
Call uiworkspace.ViewRebuild
This LotusScript code allows you to reset the View to select all documents:
Код:
Dim Session As New NotesSession
Dim uiworkspace As New NotesUIWorkspace
Dim uiview As NotesUIView
Dim view As NotesView
Dim NewViewFormula As String
NewViewFormula = |SELECT @all|
Set uiview = uiw.CurrentView
Set view = uiview.View
view.SelectionFormula = NewViewFormula
Call uiworkspace.ViewRebuild
Use the following LotusScript to modify the view selection formula so that it displays the documents using the "Prompt" method:
Код:
Dim session As New NotesSession
Dim db As NotesDatabase
Set db = session.CurrentDatabase
Dim ws As New NotesUIWorkspace
Dim FormDbColumn As Variant
FormDbColumn = Evaluate(|@Trim(@Unique(@DbColumn("";"":"";"ViewName";1)))|)
GetValue = ws.Prompt(4, "Departments", "Select Department", "",FormDbColumn)
If GetValue = "" Then
Messagebox "Operation Canceled" ,,"Department has not been selected."
Exit Sub
End If
Dim NewFormula As String
NewFormula = |SELECT Form = "Form Name" & @Begins(DepartmentName;"|& GetValue & |")|
Set uiview = ws.CurrentView
Set view = uiview.View
view.SelectionFormula = NewFormula
Call ws.ViewRebuild