LotusNotes dynamic views

I was recently asked by a customer to create a script to do the following:

1. User selects a document from a view and clicks an action button.

2. The script uses the CustID field in the highlighted document to locate all docs with this matching CustID.

3. Display all documents with this CustID in a view.

I used the following method to create a dynamic view. First, I created a view for displaying the document collection. I categorized this view by CustID field. I then created a form called "Results" with the categorized view embedded within. When you embed a view in a form or page, you can specify that only one category will be shown. The formula that I used to select which category to show is as follows:

Next, I created an action in the primary view with the following LotusScript:

Sub Click(Source As Button)
    Dim ws As New notesuiworkspace
    Dim db As notesdatabase
    Dim session As New notessession
    Set db = session.currentdatabase

        'Obtain a handle on the selected document in the view

    Dim dc As notesdocumentcollection
    Set dc = db.unprocesseddocuments
    Dim doc As notesdocument
    Set doc = dc.getfirstdocument
    If doc Is Nothing Then
        Msgbox "Please select a document"
        Exit Sub
    End If

    'Set an environment variable to the CustID of the selected document

    Call session.SetEnvironmentVar( "CustID", doc.CustID(0))

    'Create a new document using the "Results" form and open the uidocument

    Dim ndoc As notesdocument
    Set ndoc = db.createdocument
    ndoc.form = "Results"
    Dim uidoc As notesuidocument
    Set uidoc = ws.EditDocument(False, ndoc )

End Sub
This was first published in May 2001

Dig Deeper on Domino Resources - Part 7



Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:




  • iSeries tutorials

    Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...