Problem With Multiple Values in a View

I had a view with several columns that had “Show multiple values as separate entries” selected. Obviously, these columns showed fields with … wait for it…multiple values. I chose to “Show multiple values ad separate entries” because I wanted the multiple values shown alone, each in its own row. Crazy talk, huh?

Okay, so the view is set up and displaying exactly as I want it to. For example, five documents, two values in the field, show as ten rows. Perfect.

Elsewhere in the application, I had an agent that I wanted to walk the view and get the values. I know, this is revolutionary stuff, eh?

So the agent went something like this…

dim view as Notesview
set view = db.GetView (“myMultiValueView”)

dim viewcol as NotesViewCollection
set viewcol = view.AllEntries

dim viewEntry as NotesViewEntry
set viewEntry = viewcol.GetFirstEntry()

While Not (viewEntry is Nothing)

myVal = viewEntry.ColumnValues(8)

set viewEntry = viewcol.GetNextEntry(viewEntry)


Great, right? Except that “myVal” kept returning just the first value of the multivalue field. If there were two values, and consequently two rows, myVal would return the first value twice. Really infuriating when I knew the code was right. This was pretty simple stuff and was NOT working. A quick check of the help files…everything checks out. My view is good. My code is correct. What’s the problem?

Google to the rescue and I found this SPR, which explained that what I was doing was not going to work. But also provided a workaround.

dim view as Notesview
set view = db.GetView (“myMultiValueView”)

dim nav as NotesViewNavigator
set nav = view.CreateViewNav

dim viewEntry as NotesViewEntry
set viewEntry = nav.GetFirst

While Not (viewEntry is Nothing)

myVal = viewEntry.ColumnValues(8)

set viewEntry = nav.GetNext(viewEntry)


Hooray! Success! It would have been nice if this was documented in the help file, but at the end of the day (almost literally), I found the way to make it work. And, as is frequently the case, I’m blogging this mostly for other people to find the answer if they have this same problem (including my future self).

  • http://www.devinolson.net Devin Olson

    I’ve found that using NotesViewNavigator.GetNext() usually (as always,YYMV) results in faster code | quicker completions than NotesViewEntryCollection.GetNextEntry().

    In your case the “Law of Unintended Consequences” likely had a positive effect on your code Emoticon

  • http://www.browniesblog.com Mike Brown

    Or you could have made a hidden copy of the view with the “Show multiple values as separate entries” setting switched off, then done your lookup to there. Then your original code would have worked, would it not?

  • http://notesin9.com David Leedy

    Similar to what Mike suggests… I guess the “Purist” would say that you should never run agent code on a user facing view. The thinking is that the user will one day want a change that will break your agent…

    Of course my own code is FAR from “pure”. Emoticon

  • http://nathan.lotus911.com Nathan T. Freeman

    @All Except that “Show multiple values as separate entries” is INCREDIBLY useful. To wit…

    Make a set of documents with several multi-value fields, all text.

    Field 1: Red, Green, Blue
    Field 2: Me, Myself, I
    Field 3: This, That, The Other
    Field 4: Apples, Churches, Very Small Rocks

    Give them all the same values for Field 1, but randomize the values for fields 2-4

    Now create a view that has a column for each of these fields, in order. Set them all to “Show multiple values as separate entries.”

    On the first column, turn on categorization.

    Now look at your view CLOSELY.

    If you want to do something really special, try CreateViewNavigatorFromCategory(“Red”). Then walk the entries and retrieve the .columnValues.


  • http://http//www.runningnotes.net Kathy Brown

    Perhaps there was a better/cleaner way to do what I wanted, but this was just a simplification of what I was doing. This is not a user facing view. I did the “Show multiple values as separate entries” bit because I thought it would save me some code. Why loop through something that was already broken out for me? And that turned out to be true, once I used the NotesViewNavigator rather than the NotesViewEntryCollection.

  • http://null Rob Darwin

    @4- I see that your example appears to give a “free” sort in columns 2-4. Is there some other specialness I’m missing as well?

  • http://null Carl H Dreyer

    Thank you for the tip. I had exact your problem today. Nice to get help this way.

  • Cedric

    Running via a notesviewnavigator is slower to build the view (view.createnavigator) than doing the nve =view.allentries.
    This you can notice very hard when using more than 50k records in your view. It is slower to start the process, but indeed the getnext element is mush faster.
    AND it is the only way to have the result from a multivalue splitout column.

    I was looking to find out when a view/viewcolumn had the option “Show multiple values as separate entries” ticked on via code. Then it was easy to use, one or the other option. but atleast it is only available via a c++ hardly undocumented function visible.

    At the end, would we still adore lotus notes if these items did no longer appear? :)