阅读:1239回复:1
Example: Using a Notes View from LotusScript
In the preceding Visual Basic example, the datatypes MapXLib.Fields and NotesViewInfo, and the DatasetType constant miDataSetNotesView were obtained by Visual Basic through the MapX dlls and type library. In an environment such as LotusScript where the type library is not available, handles to these objects are obtained somewhat differently, as illustrated below:
Dim uiws as New NotesUIWorkspace Dim uidoc as NotesUIDocument Dim ds as Variant Dim flds As Variant Dim NDO As Variant Dim Map1 as Variant 'if the Map is embedded on a form, get the handle as follows... set uidoc = uiws.currentDocument set Map1 = uidoc.getobject("Map1") 'otherwise, create a new map object... set Map1 = createobject("MapX.Map.3") set flds = createobject("MapX.Fields.3") set NDO = createobject("MapX.NotesViewInfo.3") flds.Add "state", "BindField", 4, 0 flds.Add "value", "ValueField", 1, 1 NDO.Server = "NS1" NDO.Database = "samples\states.nsf" NDO.View = "State Info" Set ds = Map1.Datasets.Add(7, NDO, "NotesThematic", _ "BindField", , , flds) Map1.Datasets("NotesThematic").Themes.Add 0, "ValueField", _ "NotesThematic" Accessing Notes through a Notes Function Query Accessing Notes data through a function query is accomplished using a NotesQueryInfo object. The NotesQueryInfo object has Server and Database properties which behave exactly as described for the NotesViewInfo object. In addition, the NotesQueryInfo object has a third property named Query which represents the text of a query to be performed. The syntax of this query is that of a standard Notes formula. Notes function queries are generally used in conjunction with MapX Fields objects to define specifically which fields of the database record are to be used. Unlike Notes View column titles, references to record field names are not case-sensitive. Example: Using a Notes Query from Visual Basic Revisiting the preceding Visual Basic example, suppose that the database records have fields for state and value, and that the analysis you want to perform requires a thematic to be created based on database records whose state field is one of NY, TX, CA, or FL. The code can be written as follows: Dim ds as DataSet Dim flds As New MapXLib.Fields Dim NDO As New NotesQueryInfo flds.Add "state", "BindField", 4, 0 flds.Add "value", "ValueField", 1, 1 NDO.Server = "NS1" NDO.Database = "samples\states.nsf" NDO.Query = "@IsMember(state;""NY"":""TX"":""CA"":""FL"")" Set ds = Map1.Datasets.Add(miDataSetNotesQuery, NDO, "NotesThematic", "BindField", , , flds) Map1.Datasets("NotesThematic").Themes.Add 0, "ValueField", "NotesThematic" As in the first example, this can be easily adapted to LotusScript or other environments. When the type library is not available, miDataSetNotesQuery can be replaced by its numeric equivalent: 8. |
|
|