PermaLinkProgrammatically create memo with doclink on top, sig on bottom
posted Wednesday 11th, July 2007
 



It's been a while since I've posted a tech tip, so here's one that took me a little while to figure out. I've got various apps that include a button users can click to create an email message. Some fields are typically pre-populated or partially populated by the code, including recipient name(s), subject, some text in the body. The challenge this time, however, was to create a memo, insert some text and a doclink in the body, but have the user's signature (if they use one) appended at the bottom of the message. And then this partial memo was to open in the UI for the user to then continue adding text. Sounded easy, and ended up taking some mucking about. It's easy enough to create a memo in the back end, populate a few items, and open it in the UI. The problem is that the signature gets inserted at the top of the memo when it opens ...and it was driving me crazy (a short journey, I'll grant you) to get the sig on the bottom.

Fortunately, Andre Guirard had recently posted some code that was easy to adapt slightly for my purposes.

So, first off, if you're interested, you can download createMemoWithLink.lss (or you can just view the code). Create a new LotusScript script library and paste the contents of the lss into the Options area and save the script library. You can take it from there. Brief explanation: In the mail template there's a script library called CoreEmailClasses. In the Declarations area of that library, there's a class called UIMemoDocument, which includes a function called InsertSignature. I've modified that a little in a function (also called InsertSignature) in the code in the LSS. I wanted a function I could use in various apps, and just pass it a handle to the uidoc in which I want the sig appended (and I also pass a handle to the user's mail profile doc ...code to retrieve that profile doc is in the lss).

The key function in the lss (key, at least, for what I needed) is one that I called createMemoWithLink. Here's the comments that I've got in the code to explain what the function does: Create a new memo in the user's mail file. Insert some text and a doclink in the top area of the memo body, with the user's signature (if any) inserted at the bottom of the memo. The user is left with the new memo sitting open in the UI, waiting for them to complete and send the memo. NOTE: Due to the contortions we have to go through to get the sig to be placed at the bottom of the memo - after the inserted text and doclink - IF the user exits the new memo without sending, there WILL be a document left in their Drafts folder.

So it's not perfect ...since there could still be a probably-unwanted document sitting in the user's Drafts folder if they exit without saving. If anyone's got a tested solution for that, please share. But for now, this works pretty well for me. The users are happy, and that's what really matters :)

Comments :
 
 

1. Posted by Thomas Bahn - website09/06/2007 09:49 PM



Joe,

I have found a way shorter solution without the unwanted draft document in case of the exiting using formula language:
http://www.assono.de/blog.nsf/d6plinks/TBAN-75KNM5

This method has a restriction, too: The document to create the link to must be open or currently selected in a view.

Thomas
http://www.assono.de/blog.nsf/




2. Posted by Joe Litton - website09/06/2007 09:49 PM



Thomas,
Great stuff. I've posted a comment on your blog with more detail, but in general your solution is wonderful, and I am going to use it in places. I will still need to use the LotusScript in some places (since the user will not have the doclink's target document open, nor will it be selected), but at least I can now lessen the possible frequency of unwanted draft docs.

Thanks!