Manage Learn to apply best practices and optimize your operations.

LotusScript filters and attaches files to a Notes form

Using the workspace.OpenFileDialog method lets you filter file types before attaching them to a Notes field form. You can modify this method further by limiting the size of attachments. Get the steps and LotusScript you need here.

I wanted to attach a single file to a Lotus Notes field form and limit the attachment size. There are two methods to do this -- [EditInsertFileAttachment] or workspace.OpenFileDialog.

Although the [EditInsertFileAttachment] method is easier, I prefer to use workspace.OpenFileDialog because it allows you to filter the file type that you want to attach.

After implementing the workspace.OpenFileDialog method, selecting the file I wanted to attach and checking its size, I experienced a problem. The file is only attached to the form after I save the document.

To prevent this, create a form and add an editable rich-text field called Attachment. Note that the Show field delimiter option is not checked.

Related resources from SearchDomino.com:
Launch large attachments within an email from a Notes database

Shrink Lotus Notes databases with many attachments

Next to this option, add a <Choose [.EXTENSION] file> button and a computed text field called filepath. Both of these buttons are hidden in read mode.

Note: The default value is filepath.

My file constraints are set at a single .jpg that's 1 MB in size. The code for my button is as follows:

LotusScript to launch attachments
(Click on code for enlarged view and script download.)

Then I added a <Save> button to the main form. While the document was being saved, I added the rule that allows only one file to be attached. Finally, I attached the file, which was based on the file path and stored in the filepath field. Here is the code for the <Save> button:

LotusScript to launch attachments
(Click on code for enlarged view and script download.)

Do you have comments on this tip? Let us know.

This tip was submitted to the SearchDomino.com tip library by member Robert Scurtu. Please let others know how useful it is via the rating scale below. Do you have a useful Lotus Notes/Domino technical tip or code snippet to share? Submit it to our monthly tip contest and you could win a prize.

Dig Deeper on LotusScript

SearchWindowsServer
Search400
  • Favorite iSeries cheat sheets

    Here you'll find a collection of valuable cheat sheets gathered from across the iSeries/Search400.com community. These cheat ...

SearchDataCenter
SearchContentManagement
Close