I have an agent that I’ve been working on. I want to retrieve all of the documents within all of the catagories within a view. Here is my view…
Sub Initialize
Dim db As NotesDatabase
Dim view As NotesView
Dim nav As NotesViewNavigator
Dim entry As NotesViewEntry
Dim count As Integer
Set db = New NotesDatabase( "", "buildreq.nsf" )
Set catview = db.GetView( "SPRINT PCCB Meeting" )
Set catnav = catview.CreateViewNav( )
Set catentry = catnav.GetFirst( )
catcount = 0
’ begin counting categories
’ stop when there are no more categories
Do Until catentry Is Nothing
Set nav = catview.CreateViewNavFromCategory("Scheduled")
Set entry = nav.GetFirstDocument
count = 0
’ begin counting documents
’ stop when there are no more documents
Do Until entry Is Nothing
count = count + 1
Set entry = nav.GetNextDocument( entry )
Loop
Messagebox "Number of Scheduled documents = " & count,, "Scheduled Meetings"
catcount = catcount + 1
Set catentry = catnav.GetNextCategory( catentry )
Loop
Messagebox "Number of categories = " & catcount,, "Catagories"
End Sub
I would like to retrieve the catagory name (such as “scheduled”) and display it on the Messagebox line. Thanks for any suggestions that you have!!!
Ed
Subject: Documents within Catagories Loop
I believe you can just use the ColumValues property of the NotesViewEntry for whatever column your category is in, like Messagebox entry.ColumnValues(0) for the first column.
Also, check out the ChildCount property for counting. It might help you out.
Deb
Subject: RE: Documents within Catagories Loop
Deborah is right on track in both cases. Without more details, it’s hard to know exactly what you’re trying to do (and btw, none of your variable names match up with your dims; a fact that you’d know if you were using Option Declare, which you really, really, really should be doing), but if you’re trying to do what’s essentially one or more dbcolumns via lotusscript, a viewnavigator is a good way to do it; eg:
Dim db As NotesDatabase
Dim v As NotesView
Dim nav As NotesViewNavigator
Dim ve As NotesViewEntry
Set db = New NotesDatabase( “”, “buildreq.nsf” )
Set v = db.GetView( “SPRINT PCCB Meeting” )
dim msg as string
msg = “Category” & chr(9) & “Number of documents” & chr(10) _
& “============================” & chr(10)
Set nav = v.CreateViewNav( )
Set ve = nav.GetFirst( )
Do Until catentry Is Nothing
msg = msg & ve.columnvalues(0) & chr(9) & ve.childcount & chr(10)
Set ve = nav.GetNextCategory(ve)
Loop
Messagebox msg
Subject: RE: Documents within Catagories Loop
Thanks to all!!! Since I’ve only been writing script for about 2 DAYS, I guess I have a few things to learn!!!
Subject: RE: Documents within Catagories Loop
Bruce,Shouldn’t your code for the loop read
“Do Until ve Is Nothing” instead of “Do Until catentry Is Nothing”?
Ed
Subject: RE: Documents within Catagories Loop
Yep! I missed one of your original variable names when I was changing them all (since none of the original ones matched). The fact that you caught it indicates that after two days of script experience, you’re not totally lost!
Subject: RE: Documents within Catagories Loop
Well, I guess 12 years of a 3rd generation language does help from time to time.