PreviousNext…

NotesViewEntry

Check out this example in the R5 Domino Designer help file for NotesViewEntry:

Set view = db.GetView("By Category")
Set entry = view.GetEntryByKey("Breed")
If entry.IsCategory Then…

All well and good, but this doesn’t make it clear that if you derive your NotesViewEntry object another way, the IsCategory property won’t necessarily work! How have others fared with this kind of stuff? It was only yesterday I discovered that in some new code I’m doing, IsCategory always returned False unless I instantiated the NotesViewEntry object via the NotesViewNavigator class (this is in Notes 5.0.11). Doh. So, I was doing this:

Set vwLookup = db.GetView("Whatever")
Set entry = vwLookup.GetFirstEntry
Do While entry.isCategory…

Nuh-uh. Only this will do:

Set vwLookup = db.GetView("Whatever")
Set viewNav = vwLookup.CreateViewNav
Set entry = viewNav.GetFirst()
Do While entry.isCategory…

Ah, Notes development is a subtle art, no? So many ways to skin a rabbit. Oh well, I just hope this helps someone Google-ing someday…

Comments

  1. notesviewnavigators are wonderful. i've been able to do some neat stuff with them when using agents to print out stuff from views.

    one of the coolest things is the columnindentlevel. take a categorized view, several categories deep or whatever, build a style tag based on the indent level as you cycle through the entries, maybe 5 pixels per level for the left padding or something. nice.

    also, i found that wrapping html around the entries as you process rather than putting the html in the view seems to really speed things up. its always faster to manipulate a string than to get it out of a design element via the api (assuming you are going the agent / servlet route to begin with). or maybe if the view is only indexing real data, it may be faster. not sure.

    i attended a performance session at lotusphere, and the fellow was comparing various programmatic methods for getting data out of views. He showed various agents that processed data with a collection of about 5,000 docs, and the view navigator was the fastest. he said that behind the scenes its like a cursor going over the view, and because of this it is very fast.

    anyway, a little food for thought. :-)jonvon#
  2. Yup, skimming a view is always going to be quicker than I/O on a NotesDocument object. I just wish the properties and methods were more consistent, hence my talk about the NotesViewNavigator approach to "properly" initialising a NotesViewEntry object. Oh well, lesson learned.

    Just don't get me started on that guff about NotesRichTextItem inheriting from NotesItem. Oh it does does it? So how come there are two wholly different (and incompatible) methods for adding text to each of these object types eh?

    Uh oh, I'm off…Ben Poole#
  3. Right, that stuff is confusing. sounds like you have gotten to know these classes via the "using it in anger" methodology. hehe.

    please pardon my waxing rhapsodic over notesviewnavigator. i know its not a passionate subject for everyone, i just like them. but then, i'm a dork. ;-)jonvon#
  4. You've come to the right place… ;-) Ben Poole#
  5. …what about accessing a specific category's total?

    this code only got the 4 'detail' rows in the view
    …not the 'category' row with the total…as Help says it should:
    Dim session As New NotesSession
    Dim db As NotesDatabase, db2 As NotesDatabase
    Dim view As NotesView
    Dim entry As NotesViewEntry
    Dim nav As NotesViewNavigator
    Set db = session.CurrentDatabase
    Set db2 = session.GetDatabase("BELLN08/Supelco","poitmhst.nsf")
    Set view = db2.GetView("(ByItem/ValuePriorYr)")

    Set nav = view.CreateviewNavfromCategory("R30042R")

    Set entry = nav.Getfirst
    Do While Not entry Is Nothing
    If entry.IsCategory Then
    Messagebox entry.columnvalues(1) & " & entry.columnvalues(Ubound(entry.columnvalues)) "
    End If
    Set entry = nav.getnext(entry)
    Loop

    End Sub

    ….I have 4 'detail' docs in that category and with debug on, the do/loop loops 4 times
    each time with column values are accessible ( via debug ) FOR THE DETAIL DOCS -
    but no category type entry is foundMarty Mattocks#
  6. But in the example code you create a view navigator from the category - Notes will therefore disregard this, and iterate over the content of that category, not the category itself, surely?Ben Poole#
  7. Hi,

    A quick FYI. I was developing an application which hada number of documents containing multivalues in a key field / item. These were categroised in a view which showed the document multiple times, ie once in every category in the multiple value item.

    Using view.GetAllEntries to get a view entry collection and iterating over the view I discovered that many of the documents were missed, with no apparent rhyme or reason.

    Going view.CreateViewNav and then iterating through all the entries that way got them all.

    Weird but true … Thanks IBM… I needed the stress :-)


    shane hollis#

Comments on this post are now closed.

About

I’m a software architect / developer / general IT wrangler specialising in web, mobile web and middleware using things like node.js, Java, C#, PHP, HTML5 and more.

Best described as a simpleton, but kindly. You can read more here.

";