The small differences between Notes and COM sometimes matters

Had an example of this today when porting some LotusScript in Notes to VBA using COM to access Notes. In Notes the GetAllDocmentsByKey function of the NotesView class can take an array of parameters, the array being of any datatype (String, Integer etc.). It turns out that this isn’t the case for COM access where the array must be a Variant array as shown below. If you supply a String array you’ll get an error at runtime.

// declarations
Dim session NotesSession
Dim db As NotesDatabase
Dim view As NotesView
Dim dc As NotesDocumentCollection
Dim v(1) As Variant

// get session, database, views etc.
Set db = session.GetDatabase("server", "path")
Set view = db.GetView("someview")
...
...

// populate key array
v(0) = "key1"
v(1) = "key2"

// get by key
Set dc = view.GetAllDocumentsByKey(v, True)
Msgbox dc.Count

Being fair the difference is noted in the Designer help database.

Published by

lekkim

Positive, competent, out-spoken, frank and customer focused architect and developer with a strong foundation in web, cloud and product development. I'm a strong advocate for API first and cloud based solutions and development. I have a knack for being able to communicate and present technically complicated matters in conference, customer and training settings. I've previously acted as team member and leader in a product organisation.