Home > Lotus Notes Software, Lotus Notes Solution, Lotus Notes Tutorial, LotusScript, Notes Designer > Lotus Notes Embedded View – Play with selected document

Lotus Notes Embedded View – Play with selected document

We have many way to use Lotus Notes Embedded View in form for user can easy to use doc child. Let’s say that you for some reason have a form with an embedded view that lists a bunch of documents. You would like to mark one of the documents in the embedded view and get a grip of this document and do something with it. This is how I have solved it (with some help form the IBM developerWorks forums).

Step 1
In the view that is embedded in the form, add the following formula code to “Target Frame (single click)”:
@SetEnvironment( “eViewSelection”; @Text(@DocumentUniqueID))

What happens here is that an environment variable named ‘eViewSelection’ is set when clicking on a document in the view with the text value of the document unique id. In more detail this means that a row is added or updated in notes.ini that looks something like this:
$eViewSelection=00C2635582348362C125737F003C09AD

Step 2
When you somewhere else on the form need to get a hold of the document (to get a value from it or mail it as reference or something else), perhaps using lotusscript on a button, you can access it by first get the value of the environment variable that was set when clicking the document in the view and later on to use it. Here’s an example:
Sub Click(Source As Button)
On Error Goto ErrorHandler

Dim session As New NotesSession
Dim db As NotesDatabase
Dim selectedDocID As NotesDocument
Dim selectedDocIDString As String

Set db = session.CurrentDatabase
selectedDocIDString = session.GetEnvironmentString(“$eViewSelection”, False)

If(selectedDocIDString <> “”) Then
Set selectedDocID = db.GetDocumentByUNID(selectedDocIDString)
Else
Msgbox “You have to select a document!”
Exit Sub
End If

‘ Set environment variable to empty string to be ready for next run
Call session.SetEnvironmentVar(“$eViewSelection”, “” )

Exit Sub

ErrorHandler:
‘ Log error
Msgbox “An error occurred”
Exit Sub
End Sub

  1. No comments yet.
  1. No trackbacks yet.