About Me...

NotesRunningLogoRSmall.png

I'm Kathy Brown and I've been an application developer in Lotus Notes/Domino since 2005.

Prior to working in IT, I've had numerous careers including an Investment Analyst and even an Actress (long ago and far away).

And I (try to) love running!

me.jpg

kathy (at) runningnotes (dot) net

On Twitter, kjbrown13

Upcoming Races

Looking 4 Something?

Disclaimer

This is my personal blog. None of the opinions shown here represent those of my employer. In fact, forget I even have an employer. Any examples given here are strictly fictional and hypothetical and it is pure coincidence if they in any way seem like anything in real life.

« Weekend in Paradise | Main| Happy New Year »

Problem With Multiple Values in a View

Category Multiple Values Lotus Notes
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)

Wend

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)

Wend

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).

Comments

Gravatar Image1 - 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

Gravatar Image2 - 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?

Gravatar Image3 - 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

Gravatar Image4 - @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.

Discuss.

Gravatar Image5 - 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.

Gravatar Image6 - @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?

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

Post A Comment

:-D:-o:-p:-x:-(:-):-\:angry::cool::cry::emb::grin::huh::laugh::lips::rolleyes:;-)