Creating an Attach File button for an application provides the ability to insert files into the intended field. This routine prompts the user to select a file from the file finder and insert the file into the specified field.
How It Works
When the button is clicked, the cursor jumps to the specified field and launches the file finder. If the user selects a file, it is inserted in the specified field. In order to implement this solution, the target field must be set to Rich Text. Also note that the document must be in edit mode in order for the selected file to be applied to the designated field.
You can also use Rich Text Lite, which by default will place a button next to the field.
To implement this technique, create a Rich Text field on a form and make note of the field name. Next, create an action button and name it Attach File. To ensure that the button is only available when the document is in edit mode, set the "Hide When" properties for the button (see Figure 14.6).
Figure 14.6. Hide property settings for an action button
Finally, insert the following formula in the Programmer's pane. Replace FIELDNAME with the name of a Rich Text field on the form.
@Command([EditGotoField]; "FIELDNAME"); @Command([EditInsertFileAttachment])
If the document is not in edit mode or there is no Rich Text field on the form, the error message shown in Figure 14.7 will most likely display.
Figure 14.7. Error when attempting to attach a file to a document in read mode
An Introduction to the Lotus Domino Tool Suite
Getting Started with Designer
Navigating the Domino Designer Workspace
Domino Design Elements
An Introduction to Formula Language
An Introduction to LotusScript
Fundamentals of a Notes Application
Reference Library Applications
Design Enhancements Using LotusScript
Design Enhancements Using Formula Language
Miscellaneous Enhancements and Tips for Domino Databases
Application Deployment and Maintenance
Appendix A. Online Project Files and Sample Applications
Appendix B. IBM® Lotus® Notes® and Domino®Whats Next?