Subject: GetDocumentByKeys
Hi Vikas,
First of all, let me tell you, There is no method like "getDocumentbykeys". I believe you have only two methods.
a. GetDocumentByKey
b. GetAllDocumentsByKey
So, when using DocumentCollection you can use GetAllDocumentsByKey method to get all the documents under a single/multiple category. So ive just tried a simple code, which will work. Find the same below.
Dim ss As New NotesSession
Dim db As NotesDatabase
Dim vw As NotesView
Dim doc As NotesDocument
Dim dc As NotesDocumentCollection
Dim keys(1 To 2 ) As Variant
Set db=ss.CurrentDatabase
Set vw=db.GetView("User")
keys(1)="Dan"
keys(2)="12/21/2007"
Set dc=vw.GetAllDocumentsByKey(keys,True)
If dc Is Nothing Then
Msgbox "No documents returned for query."
Else
Set doc=dc.GetFirstDocument
While Not doc Is Nothing
Msgbox "Document found for input query. " & doc.Title(0)
Set doc=dc.GetNextDocument(doc)
Wend
End If
here, i haven’t done error handling for view, db etc. The form and view design details as follows:
In relation to the above code:
a. Create a form named “User” containing fields, that will hold values like name, date and a Title.(create a field called Title, as we will retrieve the field value in the code.)
b. Map the necessary fields to the view column. create a view named “User” and modify the selection formula to pick documents from the “User” form.
c. Now the first column will be “Name” which will show the user name value. It should be sorted(either Ascending/Descending). Can be categorized too. Just check the option “Show twisties when row is expandable for a better presentation”.
d. The second column will be “Date” and will show the date of creation.(here i had created a field called “dt” and gave a default value @Today and mapped it here."). Again it should be sorted(either Asc/Des) and can be categorized too.(twistie option can be fine too.)
d. Create a third column to show the title value. That need not be sorted or categorized.
Now save the view, you are done. Then you can check with the code. Create some documents with all three values and find the code retrieving the Title values from the documents matching a specific key.
Hope that helps.
Jason.