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

Dig deeper on Domino Resources - Part 4

0 comments

Oldest 

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:

SearchWinIT

Search400

  • 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 ...

SearchEnterpriseLinux

SearchVirtualDataCentre.co.UK

Close