Tip

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:
@ENVIRONMENT("CustID")

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

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

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:

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.