LOTUSSCRIPT/COM/OLE CLASSES
Lesson 3 helps you create a script that makes and sends an e-mail message. The script runs when a user chooses an action on a form. You will:
Users can invoke a form action any time a document is displayed with the form.
1. Open the "Learning LotusScript" database if it does not appear in the Design pane.
2. Select "Forms" in the Design pane, then open the "Main Topic" form in the Work pane. The form appears in the upper part of the Work pane. The Programmer's pane appears below.
3. Choose Create - Action. The actions appear on the right of the screen, and the Action properties box appears.
4. In the Action properties box, name the action "Request more info." Close or move the properties box.
5. Select LotusScript from the Run menu in the Programmer's pane.
6. Select "Click" from the list of programmable events on the Objects tab if it is not already selected.
Step B: Enter the script
1. Edit the subroutine so that it looks exactly like this (except for capitalization, which does not matter).
Step C: Compile and test the script
Do the following:
1. Choose File - Save.
2. If you get the message "Data not saved due to script error(s)," check the error at the bottom of the Programmer's pane, then double-check your typing to make sure that the script looks exactly like the one in Step B.
3. Choose Design - Preview in Notes. Alternatively, you can open the database in the Notes client and open or create a document based on the "Main Topic" form.
4. Click the "Request more info" action on the action bar. The script sends mail to you.
5. Check your mail database to make sure the memo is sent. This may take awhile depending on your mail system.
Step D: Edit the script
You may not need to edit your script after saving it, but if you do, here's how.
2. Select "Forms" in the Design pane, then open the "Main Topic" form in the Work pane.
3. If the actions do not appear on the right, drag the right-hand edge of the pane to the left until you can see the names of the actions.
4. Select the "Request more info" action.
Review: How did the script work?
The script you just created means: "I want to create a new document in the database, set the value of some of its items, and mail it."
The script is commented in Step B. In addition, notice the following:
The script you just wrote sends mail to you, regardless of what document is currently open in the database. Modify the script so that it sends mail to the author of the current document.
To do this, you need a way to access the current document (the one that's open on the workspace when the user clicks the "Request more info" button on the action bar). So far, you've used the NotesDocument class to represent documents stored in a database. This class can be used to access any document that's stored in the database. Domino uses a different class (with different properties and methods) to represent the document that's currently open on the workspace. Using the Reference tab, find the classes, methods, and properties required to:
Solution: Sending an e-mail message to the author of the current document
One correct way to write the script is as follows: