NotesViewColumn: Reading a View's Columns, Their Formulas, and Sorting in Code
You inherit an undocumented database and want to figure out what a view actually looks like: which columns it has, whether each shows a field or a formula, which are sorted, which is a category, which are hidden. Clicking through Designer column by column works — but what about a tool to inventory dozens of views?
That’s what NotesViewColumn is for. The official definition: “Represents a column in a view or folder.” It lets you read a view’s column definitions from code — the same “read the design” capability as the earlier NotesForm piece reading form design. And it lines up neatly with the recent NotesViewEntry: the values in ViewEntry.ColumnValues correspond to exactly these columns.
TL;DR
- Get it from
NotesView’sColumnsproperty (an array of all the view’s columns). - Read the title and source:
Title(column header),ItemName(the programmatic name, usually the field name),Formula(if the column is a formula). - Tell the column’s type:
IsField(value comes from a field),IsFormula(value comes from a simple function or formula),IsCategory(it’s a category column). - Sorting and display:
IsSorted,IsResortAscending,IsHidden,Width,IsResize. Position— the column’s place in the view, left to right, starting at 1. That index lines up withViewEntry.ColumnValues.
Getting and walking them
Dim view As NotesViewSet view = db.GetView("Orders")Dim col As NotesViewColumnForall col In view.Columns Print col.Position & ": " & col.Title & " (" & col.ItemName & ")"End Forallview.Columns gives you the array of the view’s columns; read each one’s properties and you’ve inventoried the whole view’s column structure.
What each property says
| Property | Holds |
|---|---|
Title | column header (read-write) |
ItemName | ”the programmatic name of a column, which is usually the field (item) name” (read-only) |
Formula | the column’s formula (read-write, if it’s a formula column) |
Position | the column’s place, left to right starting at 1 (read-only) |
IsField | whether the value comes from a field (read-only) |
IsFormula | whether the value comes from a simple function / formula (read-only) |
IsCategory | whether it’s a category column (read-only) |
IsSorted | whether it auto-sorts (read-write) |
IsHidden | whether it’s hidden (read-write) |
Width / IsResize | column width / whether resizable |
To “auto-generate view documentation,” these are the key ones: IsField / IsFormula distinguish a column that shows a field directly from one that’s computed; if it’s a formula, read Formula to pull that formula out.
Lining it up with NotesViewEntry
This is NotesViewColumn’s most useful pairing. The recent NotesViewEntry.ColumnValues piece flagged a trap: the n in ColumnValues(n) is the view’s column order, not a field name.
NotesViewColumn.Position is the source of that n. So you can build a “Position → Title / ItemName” lookup from view.Columns first, then read each entry’s ColumnValues and map “the value in column n” back to “what that column is” — which is the key combination for dynamic reports and exports where the columns aren’t hard-coded:
' build a column lookup firstDim titles List As StringForall c In view.Columns titles(Cstr(c.Position)) = c.TitleEnd Forall' then reading an entry's values maps back to column namesWhat about Java and SSJS?
| Language | Counterpart | Obtained via |
|---|---|---|
Java (lotus.domino.*) | ViewColumn | view.getColumns() |
| SSJS / XPages | ViewColumn | view.getColumns() |
Consistent across all three: getColumns() for the array, getItemName() / getFormula() / isCategory() and so on. When you write a Domino design-inventory or documentation tool, the column-property mapping here carries straight over.