Getting a handle on a selected document in a view

I am sure this is something really simple but I am hitting a wall with it right now. I have a view that will show a list of documents. I want the user to be able to click on one of the entries in the view and then click a button that will change that documents position in a view. This means that I need to get a handle on the selected document that includes its parents view. This is my code so far

Set DocA = getselecteddoc

Set view = getview(“Outline”)

If DocA.IsResponse Then

Set DocB = view.GetPrevSibling(DocA)

countB = DocB.GetItemValue("CountChild")(0)

Else

Set DocB = view.GetPrevDocument(DocA)

countB = DocB.GetItemValue("CountPar")(0)

End If

getselecteddoc gets a handle on the document using the notesSession which doesn’t give me the parent view therefore when I try to say getprevsibling(DocA) it says DocA doesn’t exist in the view. Anybody have any idea around this?

Subject: getting a handle on a selected document in a view

Try db.UnprocessedDocuments to get the DocCollection, then get the doc that you want. collection.Count should be =1 if you want them to only select one doc.

You may need to then get a new handle on the selected document with view.GetDocumentByKey before you can use the Sibling stuff.

It would be best to use 2 separate handles for this rather than trying to use the same one.

Good luck.

Subject: getting a handle on a selected document in a view

You can use NotesDatabase.UnprocessedDocuments to get a NotesDOcumentCollection of selected documents. If there’s only one, it shouldn’t matter. Then you can get the first document of the collection and use NotesDocument.ParentView.

You could also use NotesUIView.CaretNoteID. Like this:

Dim ws As New NotesUIWorkspace

Dim uiview As NotesUIView

Dim s As New NotesSession

Dim db As NotesDatabase

Dim doc As NotesDocument

Dim v as NotesView

Set uiview = ws.CurrentView

Set db = s.CurrentDatabase

Set doc = db.GetDocumentByID(uiview.CaretNoteID)

Set v = doc.ParentView