Friday, November 21, 2008

Beware of NotesView.getColumnValues

It's probably undocumented for a reason (not complete?).

If you use this in a webapp, and run as web user, it ignores readers-fields, and returns all column values. This is similar to the LS Evaluate-behavior when you do @DbLookup/@DbColumn.

Also.. If you do NotesView.FTSearch, getColumnValues returns all values, instead of only the ft-search filtered values.

Simple function that does the same as NotesView.getColumnValues, safer, but a little slower:

Function columnValues( view As NotesView, Byval columnIndex As Integer ) As Variant
On Error Goto bubbleError

'Create empty dynamic array
columnValues = Split( "" )

Dim entryCol As NotesViewEntryCollection, entry As NotesViewEntry
Set entryCol = view.AllEntries
Set entry = entryCol.GetFirstEntry
While Not entry Is Nothing
If entry.IsValid Then
columnValues = Arrayappend( columnValues, entry.ColumnValues( columnIndex ) )
End If

Set entry = entryCol.GetNextEntry( entry )
Wend

columnValues = Fulltrim( columnValues )

Exit Function
bubbleError:
Error Err, Err
End Function

0 comments: