|
|
|
|
|
|
|
|
|
|
LotusScript's Evaluate command (continued)
The function returns the Variant value created by the call to the @Adjust function. Here's how it may be used. The following code is contained in a button on an open document. A date value is retrieved from a field on the document, and numerous documents are created (for three successive dates).
1.Dim ws As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Dim db As NotesDatabase
Dim doc As NotesDocument
Dim dateText As String
Dim temp As Variant
Dim x As Long
2.Set uidoc = ws.CurrentDocument
3.Set db = uidoc.Document.ParentDatabase
4.dateText = ui.FieldGetText ( "StartDate" )
5.temp = DateValue( dateText )
6.For x = 1 to 3
7.Set doc = db.CreateDocument
8.doc.Form = "Test"
9.newDate = AdjustDate(0, 0, x, temp)
10.doc.StartDate = newDate(0)
11.Call doc.Save(True,False)
Next x
|
The explanation for each of the numbered lines is as follows:
- The current environment is accessed.
- The currently open document is accessed.
- The NotesDatabase object is instantiated; it is necessary to create new documents.
- The date value is retreived from open document. This is the starting date for creating new documents.
- The text date value is changed to a date value.
- A for loop is used to create three new documents.
- A new document is created.
- The form field is set.
- The AdjustDate function is used to increment the date value with the loop index value.
- The StartDate value on the field is populated using the function return value.
- The new document is saved.
The previous code is application specific, but it does showcase the use of Evaluate. The next example is simpler; it uses the @Name function.
Dim userName As Variant
username = Evaluate( |@Name([CN];@UserName)|)
MsgBox "Your common name is: " & username(0),0,"Username"
|
Usage rules What are the rules to keep in mind when you're working with the LotusScript Evaluate function?
When you're working with the Evaluate function, keep the following points in mind.
The first parameter is a string value. Ensure that you use the proper syntax, particularly in cases where the @Function referenced within the Evaluate function contains parameters within quotation marks.
Here are a couple examples:
When passing the parameter enclosed in quotations marks, the parameters of the @function must be included in a pair of quotation marks:
Result = Evaluate( "@ReplaceSubstring(SourceField; ""errr"";""error"")", doc)
|
When passing the parameter enclosed in vertical bars, the parameters of the @function must be enclosed in a single set of quotation marks:
Result = Evaluate(|@ReplaceSubstring(SourceField; "errr";"error")|, doc)
|
The parameters within the referenced @function must be either a field name, within the document, or text. Extended syntax is not allowed. Also, in Notes releases 4.1x and 4.5x, you are not allowed to use a LotusScript variable to set a parameter.
[ Prev | Next ]
|
|
|
|
|
|
-- Advertisement --
AUTOMATE LOTUS NOTES USER ID MANAGEMENT
ID Manager 4.5 from HELP Software provides a new level of automaton for managing Lotus Notes IDs. ID Manager lets Lotus Notes administrators get out of the business of creating and managing user IDs. Use our ROI calculator to see how quickly ID Manager will pay for itself.
Learn more about HELP Software products |
-- Advertisement --
INTEGRA FOR NOTES - EXHIBITING AT LOTUSPHERE NEXT JANUARY (Booth 708)
Integrate Excel and Word directly into your Notes applications optionally without coding.
- Still have deep programmatic control through Integra's Event Driven model.
- Typically experience a 10x boost in productivity.
- Use the power of Excel to generate Excel graphs, pivot tables, etc.
- Incorporate MS-Office documents as a part of your business process, generate Excel based quotations from Notes CRM applications, with a "save back" to Notes option.
Allow users to use a Notes client, web browser or generate Integra scheduled all within the same license.
More information as well as a Free 15-day evaluation available from www.integra4notes.com/download. |
|
|
|
|
|
|
|
|