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.
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
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:
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.