Launching the first attachment of a document from a docLink
I had a request to send a docLink in an email
message that when clicked would not just open the Lotus Notes document, but
would rather open the first attachment stored in the document.
I knew I could do it with a url from the browser
with something like this:
server/filepath/filename/view/docid/$file/filename?openelement
But I wasn't sure how to meet the requirement in
the Notes client with a docLink.
I spoke with Chris Toohey and Jamie Magee and they
both what I will discuss below, except both indicated that the url would work in
the notes client use if you put
Notes://server/filepath/filename/view/docid/$file/filename?openelement.
The idea worked, but I couldn't get the url to
work. But a regular docLink worked which is better than a URL.
First create a form, call it (launcher) | launcher.
The form does not need any fields on it. Set the Form Launch property>Auto
Launch to First Attachment.
Then create a view, call it (fileLauncher) |
fileLauncher. Put one column in the view. The formula for the column should be
@Text(@documentUniqueId). Make sure the column is sorted.
In the Form Formula of the view, put "launcher".
To create a mail message with a docLink that
launches the attachment, I then created an action
button on the form where the attachments are stored with the following
code:
Sub Click(Source As Button)
Dim workspace As
New NotesUIWorkspace
Dim uiDoc As NotesUidocument
Dim doc As
NotesDocument
Dim session As New NotesSession
Dim db As
NotesDatabase
Dim view As NotesView
Dim launcherDoc As
NotesDocument
Dim memo As NotesDocument
Dim rtitem As
NotesRichTextItem
Set uidoc = workspace.currentdocument
Set doc =
uidoc.document
Set db = session.currentdatabase
Set view =
db.getview("fileLauncher")
Set launcherDoc =
view.GetDocumentByKey(doc.UniversalID)
If launcherDoc Is Nothing
Then
Else
Set memo = db.CreateDocument
Set rtitem = New
NotesRichTextItem(memo,"Body")
Call
rtitem.AppendDocLink(launcherDoc,"launch attachment")
memo.sendto= "Betsy
Thiede"
Call memo.Send(False)
End If
End Sub
When I received the mail message, and clicked on
the docLink, the attachment opened up just like I wanted it to. Hooray.
If I just used the code listed below, the document
opened, but not the attachment.
Sub Click(Source As Button)
Dim workspace As
New NotesUIWorkspace
Dim uiDoc As NotesUidocument
Dim doc As
NotesDocument
Dim session As New NotesSession
Dim db As
NotesDatabase
Dim view As NotesView
Dim launcherDoc As
NotesDocument
Dim memo As NotesDocument
Dim rtitem As
NotesRichTextItem
Set uidoc = workspace.currentdocument
Set
doc = uidoc.document
Set db = session.currentdatabase
Set
memo = db.CreateDocument
Set rtitem = New
NotesRichTextItem(memo,"Body")
Call
rtitem.AppendDocLink(doc,"docLink")
memo.sendto= "Betsy
Thiede"
Call memo.Send(False)
End Sub