Genii Weblog

Civility in critiquing the ideas of others is no vice. Rudeness in defending your own ideas is no virtue.

Tue 15 Mar 2005, 10:07 PM
I love the fact that there is always something new to learn, or perhaps just to use for the first time, in Notes.  I had a customer write in who wanted to remove attachments from a document, put each one in a separate document, replace the original attachment with a link to the new document (for each attachment), and then auto-launch the attachment when they clicked on the link.

As the customer already knew, our Midas Rich Text LSX was easily able to do the first few steps, and I have even shown it before at conferences (and it is mostly there in our Copy Rich Text Field sample on our Sample DBs page).  The big question was, how hard would it be to auto-launch the attachments.

Well, you know the saying, "When you have a hammer, every problem looks like a nail."  My reaction was to start doing fancy things with the AppendHotspot method, using formula to detach the attachments and execute...

Duh!  It suddenly occurred to me to look in the launch properties for a form, and sure enough, there is a property that says "Auto launch first attachment".  (See below)  So, I undid my fancy steps, created a new form called Launch Form, then set the new documents being created to that form.  Voila!  It worked perfectly, well almost.  I did have to go back and change the code to sign the document so that the auto-launch did not trigger and ECL alert, but then it worked without my having to do any magic.  Sometimes a different tool will work in place of a hammer, and Notes is practically a Swiss Army knife.  Lesson learned.  (By the way, the customer uses R4.6x clients and R5 servers, so I was glad to find that this is a feature that has been around for a long time)

For those who care, the sample db is available upon request, and the code snippet used to create the attachment form is simply:

Set docAttachment = New NotesDocument(dbTo)
docAttachment.Form = "Launch Form"
docAttachment.Subject = "Attachment - " & rtchunkFrom.FileName
Set rtitemAttachment = New GeniiRTItem
Call rtitemAttachment.CreateBackend(docAttachment.Handle, "Body", True)
Call rtitemAttachment.Everything.AppendRTChunk(rtchunkFrom)
Call docAttachment.MakeResponse(docTo)
Call docAttachment.Sign
Call docAttachment.Save(True, False)
Call rtchunkFrom.AppendLink("<access at " & rtchunkFrom.FileName & ">", dbTo.ReplicaID, view.UniversalID, docAttachment.UniversalID, "Attached: " & rtchunkFrom.FileName)
Delete rtitemAttachment
Delete docAttachment

Copyright 2005 Genii Software Ltd.