I need to create an “Index” document that contains document subject & description of each document within the database. With some examples from the Designer Help, I’ve created a test “index” that creates a table with 200 rows of test data. I’m missing the 2 important pieces: 1) replace the count of 200 with the actual number of documents - how do I count the number of documents in my current database?
- I’m looking for an example that will position me to the first document in the database, retrieve the document properties, write to my table, (I have the code for retrieving document properties working, I just need to position to the first document and write to the new document
then move on to the following document. I’m confused on how to switch between the two documents, the one I’m reading, then back to the one I’m writing)
Since I have the new document created with the table, I’ve only included the piece of code that populates the table:
REM Populate table
Dim rtnav As NotesRichTextNavigator
Set rtnav = body.CreateNavigator
Call rtnav.FindFirstElement(RTELEM_TYPE_TABLECELL)
For iRow% = 1 To 200 Step 1
For iColumn% = 1 To 2 Step 1
REM get values
subj = doc.GetItemValue( "Subject" )
descr = doc.GetItemValue( "$$Description")
Call body.BeginInsert(rtnav)
If iColumn% = 1 Then
Call body.AppendText("Subject: " & (subj ( 0 ) ))
Else
If icolumn% = 2 Then
Call body.AppendText("Description: " & (descr (0) ))
End If
End If
Call body.EndInsert
Diane
Subject: looping & retrieving document properties
Diane,
To access the number of documents in a database, use the NotesDocumentCollection object
dim session as new notessession
dim db as notesdatabase
set db=session.currentdatabase
dim coll as notesdocumentcollection
set coll=db.alldocuments
the number of documents in the collection would be found using…
coll.count
Using the collection, you can then loop through like this
Dim doc as notesdocument
set doc=coll.getfirstdocument
do until doc is nothing
'table and properties code here
set doc=coll.getnextdocument(doc)
Loop
Hope this points you in the right direction
Mike
Subject: RE: looping & retrieving document properties
Mike, Thank you for your example, as I work through this, I’m thinking I need something like this:
dim doc as notesdocumet
dim doc2 as notesdocument
set doc=coll.getfirstdocument
get doc property info
go to doc2
write properties to doc2
set doc=coll.getnextdocument(doc)
Your example is very good, I just need a little more clarification when switching between the document that I’m reading and the document that I’m writing to.
Thanks again,
Diane
Subject: RE: looping & retrieving document properties
You don’t need to “switch” to another document. You have two NotesDocument objects declared, you load the document you want to read from into one, the document you want to write to into the other, and you use the appropriate variable name to say which document you’re operating on.
It looks like you’re building a rich text field in your “index” document. You don’t need to use BeginInsert and EndInsert to add to the end of what you already have. However, you will have to add paragraph breaks using AddNewLine.