I need Visual Basic code to scroll to a document in notes.

Hi,
I need VB code (if possible, if not, then I'll try and decypher notes script) to navigate within notes and select a certain document within a CATEGORIZED view.

If I use:
objNotesws.OpenDatabase "server", "database", "view", "document"
then it takes me to the title of that document.  I need to drill down and actually select the relevant document, so that the user can then open the document within notes.
Ie:
I need:
>Title1
   >Title2
      >Title 3.
But I get:
>Title1
I hope this makes sense.
deljonesAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
GunsenConnect With a Mentor Commented:
For a NotesR4.6 client You could use the NotesUIView class - SelectDocument method.
Trigged by QueryOpen-event you could use following code:

Sub Queryopen(Source As Notesuiview, Continue As Variant)
Dim workspace As New NotesUIWorkspace
Dim session As New NotesSession
Dim db As NotesDatabase
Dim view As NotesView
     
Dim key(1 To 3) As String
key(1)=session.GetEnvironmentString( "MyTitle1" )
key(2)=session.GetEnvironmentString( "MyTitle2" )
key(3)=session.GetEnvironmentString( "MyTitle3" )

If key(1)<>"" Then
  Set db = session.CurrentDatabase
  Set view = db.GetView("View")
  Set doc = view.GetDocumentbykey(key)
  Call Source.SelectDocument(doc)
  Call session.SetEnvironmentVar( "MyTitle1", "" )
End If
0
 
ghassan99Commented:
u want a categorized view to appear in a VB prog and the user to be able to choose any document and get it displayed in notes? is that it?
0
 
deljonesAuthor Commented:
Not quite.  I've got some Oracle tables from which I get some information that is also stored on a notes database.  Then in my vb prog, the user selects a record, then I want to switch to notes, to the relevant document in the notes view.  Then they can do what they want with this docuement in notes.  The problem is, that because the view in notes is categorised, the record selected when I open the view (with OpenDatabase) is the very high level 'title' rather than the actual document I want.

Phew...
0
[Webinar] Kill tickets & tabs using PowerShell

Are you tired of cycling through the same browser tabs everyday to close the same repetitive tickets? In this webinar JumpCloud will show how you can leverage RESTful APIs to build your own PowerShell modules to kill tickets & tabs using the PowerShell command Invoke-RestMethod.

 
ghassan99Commented:
ok u mean the parent document is the one that is getting selected, and u want the VB prog to open the view in notes with the right child document selected.  I will see about that.
0
 
ghassan99Commented:
Notes will always locate documents based on the first sorted column in a view.  Since the first one is the categorized view, Notes will stop there in the first category that contains the document even within nested categories. I suggest the following work around.  Instead of Notes drilling down to the document, open the document for the users. Check this snippet of code:

Public session As NOTESSESSION
Public db As NOTESDATABASE
Public view As NOTESVIEW
Public doc As NOTESDOCUMENT
Public ws As NOTESUIWORKSPACE
Public testvar As Variant

Private Sub Command1_Click()
   Set session = CreateObject("Notes.NotesSession")
   Set db = session.GETDATABASE("", "test.nsf")
   Set ws = CreateObject("Notes.NOTESUIWORKSPACE")
   Call ws.OPENDATABASE("", "test.nsf", "test", "Kenan")
   Set view = db.GETVIEW("test")
   Set doc = view.GETFIRSTDOCUMENT
   
   Do While Not (doc Is Nothing)
      testvar = doc.GETITEMVALUE("name")
      If testvar(0) = "Kenan" Then Exit Do
      Set doc = view.GETNEXTDOCUMENT(doc)
   Wend

   Call ws.EDITDOCUMENT(False, doc)
   Set doc = Nothing
   Set view = Nothing
   Set db = Nothing
   Set session = Nothing
End Sub

Modify this to ur own needs. u have to put a field as a serach criteria to look for a specific doc.
0
 
deljonesAuthor Commented:
Thanks for your answer ghassan99,
I already have code to do this via an uncategorised view:

Set sess = CreateObject("notes.notessession")
Set db = sess.getdatabase("server", "database")
Set view = db.getView("UncategorisedView")
set doc = view.getdocumentbykey
ws.editdocument false, doc

But I really need to navigate to the document in a categorised view.

Is there a way of executing lotus @commands in visual basic?


0
 
ghassan99Commented:
I truly believe its not possible, I tried creating a hidden view, but it will affect the categorization.  Notes will just encounter the categories first since they are the first sorted column.  
0
 
GunsenCommented:
A lookup in a categorized view - should be the same as an uncategorized.
If you use a key like "Title1\Title2\Title3" you should try replacing code with this:

Dim key(1 To 3) As String
key(1)="Title1"
key(2)="Title2"
key(3)="Title3"
...
Set doc = view.GetDocumentByKey( key )
...
Regards
Gunsen
0
 
deljonesAuthor Commented:
This code will only work with the back-end navigation.  I can find the document I want via an uncategorised view, but I can't navigate to it and highlight it with this categorised view on the UI.  I think the only way you can actually highlight a document in a view is with the

OpenDatabase server, database, view, key

command, but as I say, this only takes me to the category, rather than the actual document.  I tried putting an array on the key bit of the command, but that didn't work either.
0
 
ghassan99Commented:
yes, the opendatabase method is the only way available, coz looking up keys is based on a sorted column.  Gunsen's proposal will just move u closer to the category.  No solution for this:)
0
 
mchampouCommented:
Sorry I didn't read through all the previous post, perhaps someone already went this way ...

After having found the document, you could put the DocUniqueID of the document in a profile document within the database of in an environment variable and then call an agent that will select the document.

The agent will fetch the DocumentUniqueID and then perform a SELECT on the UNIQUEID

ex:

UNID := @Environment("$TheDocIwantSelected")
SELECT @IsMember(UNID;@DocumentUniqueID)

...

anyway, I suspect to have an error in my code up there (wich parameter the @IsMember uses) and I don't know if the category will be open ...

At worse, and once the document is selected, you can alway call @Command([ViewShowOnlySelected]) followed by a @Command([ViewExpandAll]) or something like that ... that will make only the selected document appear ...

If it solves your problem, I'll post this as an answer.

mchampou
0
All Courses

From novice to tech pro — start learning today.