Showing posts with label Lotus Notes. Show all posts
Showing posts with label Lotus Notes. Show all posts

Thursday, August 18, 2011

Formatting a Lotus Notes Document - Part 1

There are a few tricks that I use the most when designing a Lotus Notes document template. One of them is making sure that text is readable. I've been told that Lotus Notes developers have come a long way and that the concepts of design already old in web development, have also been brought into Lotus Notes and that no one does things like this anymore. No, they do. I've seen it and I have proof.

There is a a simple design rule I try to implement at all times.

Use a table of 6.5 width to hold content


If you can help it, never use Fit to Margins. It looks terrible and makes forms harder to read. There is a reason Readability, book readers, tablets, newspapers and other forms of content distribution don't display text across the full width of a page. Long and wide areas of text becomes unreadable. The human eye doesn't track well across 14 inches of text on the same line, a prospect which grows increasingly difficult as length increases.


By keeping content inside a Fixed width table, you are staying in control of your content. You are determining where the user should move next and you are subtly guiding the flow of the form.

As software developers, we are increasingly required to not only understand how to develop the coding part of software, but to understand how to influence human interaction through a software interface.

Friday, August 5, 2011

Lotus Notes Resources

Unfortunately, if you're a Lotus Notes developer StackOverflow doesn't typically have the answer and user base to answer your question. There are, however, two standard places to find what you're looking for. The Lotus Notes Forums ( Lotus Notes 8 Forum, Lotus Notes 6 & 7 Forum ) on the IBM website. They aren't readily apparent on the IBM website and if you think about it, the answer becomes clear.


Remember the video of Steve Ballmer leading the "developers, developers, developers" chant? Microsoft made it clear that it is focused on winning over developers. IBM, on the other hand, is mainly focused on winning over managers (or those with the purse strings).

I don't point that out to make either party look bad, but it does give us an idea of where we'll need to look when searching for resources and tutorials to find out how to best use the tools at our disposal.

All that said, the forums are a great place to find answer to Lotus Notes persistent questions:

Xpages Resources and Tutorials

The absolute best resource for learning XPages is the demonstration example, which can be found here (http://208.85.190.65/demos/demoapp.nsf). XPages heavily uses the Dojo toolkit ( http://dojotoolkit.org/ ), which is much like jQuery (similar concepts, same ideas; use XMLHttpRequest to drive your application).

Still, it doesn't address the main problem with XPages, which is the poor user authentication process. You can't just use the Lotus Notes account to authenticate. You have to set the Internet Password settings in every individual user account. A very tedious process if you didn't start off from the beginning using internet settings. Even in the Lotus Notes web browser it can't authenticate.

There are ways around this using Tivoli (free if you are licensed for Domino Server) or some other user account management program and as always you could write your own and reinvent the wheel.

However, if you can't answer the authentication problem, then you won't get the most out of XPages.

Thursday, August 4, 2011

Send an HTML email in Lotus Notes

Below is a fairly straightfoward way to send an HTML email in Lotus Notes. You can place it just about anywhere, but I recommend placing it in an Agent. That will allow you to work against more data than using it strictly inside a document.

Notice "Call stream.WriteText()", which allows us to add our HTML formatting. You'll still have to follow the normal rules of SMTP. For instance, including CSS in your email will require to call your stylesheet.

Set docMail = db.CreateDocument

'// COMPOSE MESSAGE
session.ConvertMIME = False ' Do not convert MIME to rich text
docMail.Form = "Memo"
docMail.Subject = docNotify.emailSubject(0)
docMail.Principal = "Automated Notification"

'// CREATE MAIN MIME MESSAGE
Set stream = session.CreateStream
Set MIMERoot = docMail.CreateMIMEEntity ' message root

'// CREATE CHILD ENTITIES
Set mime = MIMERoot.CreateChildEntity
Set header = MIMERoot.getNthHeader("Content-Type")
Call header.SetHeaderVal("multipart/related")


'// HEADER
Call stream.WriteText(| |) Call stream.WriteText(|

|) Call stream.WriteText(| 
Text | & document.field(0) & |
|) '// BODY Call stream.WriteText(| |) Call stream.WriteText(| | & document.field(0) & | |) Call stream.WriteText(|
|) '// FOOTER Call stream.WriteText(| |) Call stream.WriteText(| |) Call stream.WriteText(|

Text:
|)
Call stream.WriteText(| Database: | & db.Title & |
|)
Call stream.WriteText(| View: | & document.field(0) & |
|) Call mime.SetContentFromText(stream,"text/html",ENC_NONE) Call stream.Close Set header = mime.CreateHeader("Content-ID") Call header.SetHeaderVal("") Call docMail.Send( False, docNotify.notificationList ) '// RESTORE CONVERSION session.ConvertMIME = True


Optional Coding Parameters you may need:


'// OPTIONAL - Create inline image reference
' Set mime = MIMERoot.CreateChildEntity
' Call stream.Open("http://www.myserver.com/applications/mmail.nsf/" & imagename & "?OpenImageResource")
' Call mime.SetContentFromBytes(stream, "image/jpeg", ENC_NONE)
' Call stream.Close
' Call mime.EncodeContent(ENC_BASE64)


Download the code

There is actually a good book out there for learning more about Lotus Notes. It's one of the few:

Tuesday, August 2, 2011

Saving a Lotus Notes document as Rtf or Word

This is probably not the best solution, but it's quick and it makes use of some built in Lotus Notes functionality.

Assumptions:

  1. We're going to assume that you can write a document to the user’s hard drive.
  2. If you can't, why can't you? If your IT group can stop you from saving, then they can create a folder that can be written to.
Add this code to a button:

@Command([FileExport];"Microsoft RTF";"c:\\Folder\\FileName.doc");



Screenshot in Lotus Notes Designer
Word understands what to do with an RTF. To take advantage of that, we can save the file with a .doc extension and Word will open the document correctly. However, there could be margin issues. Make sure that the text in your document is in a table that has a width of no more than 6.5 inches (see this post for help). This will prevent clipping.


From a standards standpoint, we use the 6.5 inch table width on all our forms instead of using "Fit to Margins" settings. This gives us more control over how the user sees and interacts with the form.