Tip

Moving To A Particular Document In A View Using Script (In Notes 4.6)

The only way (I know of) to accomplish this is via the SelectDocument Method in
the NotesUIView Class. The problem is that the NotesUIView Class is only
available through the QueryRecalc event in the view.

The Solution involves the following:

1. The view you want to open to a particular position.
2. A hidden view with all documents sorted by a key value (in my case I used a
section number).
3. Script code in the QueryRecalc event in 1. that uses 2. to find the right
document and the SelectDocument method to select it in 1.
4. Some @Function code that triggers the QueryRecalc Event in 1.
Here is some LotusScript code to paste into the QueryRecalc event. I use
Environment variables to pass parameters to control the execution of the code:

Sub Queryrecalc(Source As Notesuiview, Continue As Variant)
Dim session As New NotesSession
Dim workspace As New NotesUIWorkspace
Dim view As NotesView
Dim db As NotesDatabase
Dim doc As NotesDocument

Set db = session.CurrentDatabase

searchDocument = session.GetEnvironmentString("EnvSearchDocument")
key = session.GetEnvironmentString("EnvKey")

If searchDocument = "Yes" Then
'Now reset to prevent the code from being activated by the next view
refresh
searchDocument = "No"
Call session.SetEnvironmentVar("EnvSearchDocument", searchDocument)
Set view = db.GetView("vKEYLOOKUP") 'Hidden lookup view with key
values sorted
Set doc = view.GetDocumentByKey(key)
If Not doc Is Nothing Then
Call Source.SelectDocument(doc) 'This will do the job
Else
Messagebox "The document with the key value " + key + " was not
found", 64, "*Find Document"
End If
End If
End Sub

The following @Function code will execute the Script code when the view is
refreshed with @Command([ViewRefreshFields]). It lets the user input a a key
value and moves to the corresponding document in the view. In my case i used it
to let the user enter a section number and move the view marker to the right
document.
If the Preview Pane is turned on the document will be displayed instantly.

_section := @Prompt([OKCANCELEDIT]; "Find Document"; "Enter a key"; ""; "");
@Environment("EnvKey"; _key);
@Environment("EnvSearchDocument"; "Yes");
@Command([OpenView]; "vVIEWTOOPEN");
@Command([ViewRefreshFields])
END

This was first published in November 2000

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.