How are the NotesViewEntries property ColumnValues defined?

Hi there,

I have a problem with the property ColumnValues of the NotesViewEntry class. I wrote a generic class that allows to export any view, no calenderviews though, and it works quite well. But I got problems with those columns that are used for color changes, invisble pre-sort, ... and so on.

Looking int othe view one can sess that these columns are clearly marked as hidden, which works well in the UI. But in the ColumnValues property a column with content is created for them.If for every column in the design a column in that property would exist - no problem. But some "hidden" columns are indeed hidden and others are not.

This is of course a big problem for my class as it does not expect to get hidden column values in that property.

So how can I find out which columns in a view will be stored in viewentry.columnvalues ?

Using the Views Columns property does also not help, as the hidden property tells me that the column will not be shown in the UI, but it may appear in the NotesEntry.Columnvalues property.

Kind Regards

Jochen (Joe) Herrmann

This is a tricky one: ColumnValues contains ALL columns (even hidden ones) as long as they do not contain constant OR special values as you can read in the help for this property:

Usage

A column value is not returned if it is determined by:

  • A formula containing a UI-only function such as @IsExpandable or @DocNumber.
  • A constant.

Unfortunately if you get the NotesView.Columns- Property it WILL contain these columns... So matching the title of a column with its content from ColumnValues is not easy. I have a function called "IsColumnFiltered" to check, if a column will appear in columnvalues. It gets a Column from NotesView.Columns as parameter:

	Private Function isColumnFiltered (varTestColumn As Variant) As Boolean
		On Error GoTo ErrorRoutine
'===================================================================================================================================
		'-----------------------------------------------------------------
		' Function to return True/False whether column formula is considered 
		' a UI only one.
		'
		' The DoExport routine uses the ColumnValues property of the NotesViewEntry
		' which does not return any values for columns with UI only formulas, such
		' as @IsExpandable and @DocNumber
		'
		' We use the Columns property of the View to return all the columns in 
		' the view we are going to export.  Mainly this is needed to gain access
		' to the titles of the columns for the export, as well as being vital to 
		' allowing users to customize the export.  Then, in script, we need to remove 
		' any columns that won't be returned by the ColumnValues property, by 
		' checking each in this function.
		'
		' In future version of Lotus Notes, Lotus may add new UI only functions 
		' which will need to be added to the list we check.  That can be done by
		' adding another element in the arrUIFormula array used below.
		'-----------------------------------------------------------------
	isColumnFiltered = False
	
	Dim arrUIFormula(8) As String
	Dim strTestFormula As String
	Dim z As Integer
	
	'List of UI formulas that won't be picked up by ColumnValues property
	'as taken from Notes Designer Help document named
	'"Formulas that look for values in columns and views"
	arrUIFormula(0) = "@IsExpandable"
	arrUIFormula(1) = "@DocNumber"
	arrUIFormula(2) = "@DocChildren"
	arrUIFormula(3) = "@DocDescendants"
	arrUIFormula(4) = "@DocParentNumber"
	arrUIFormula(5) = "@DocSiblings"
	arrUIFormula(6) = "@IsCategory"
	arrUIFormula(7) = "@DocLevel"
	arrUIFormula(8) = "@Responses"
	strTestFormula = varTestColumn.Formula
	
	'Test for any UI only formulas
	For z = 0 To UBound(arrUIFormula)
		If InStr(1, strTestFormula, arrUIFormula(z), 5) <> 0 Then
			'If we find a UI only formula in the column, exit the 
			'function and return true so the export script won't attempt
			'to use that column.
			isColumnFiltered = True
			Exit Function
		End If
	Next
	
	'Test for a constant value that will be ignored by column search used by
	'ColumnValues property.
	If varTestColumn.IsFormula And InStr(1, strTestFormula, "@", 5) = 0 And _
	InStr(1, strTestFormula, "+", 5) = 0 And InStr(1, strTestFormula, "=", 5) = 0 Then
		'Possibly is a constant-value column formula.  If so, the ColumnValues
		'property will ignore it.
		'
		'To avoid this, we tested that the column value is a formula, thus 
		'ruling out a field only column formula.  Also, we tested for the 
		'existance of an @ symbol or a + symbol which should most of the time 
		'mean that the formula is not a constant-value.  The only cases that 
		'are likely to result in true are cases where the column formula is
		'equal to a single string, such as "String".  In this case we'll set
		'IsUIColumn to true because the ColumnValues property will ignore it.
		'
		'Likely the worst case is that the column is considered a UI only 
		'column and its title is not exported, but the data will still be
		'exported in the DoExport routine because the ColumnValues property
		'will return it.  In that case, the titles in the spreadsheet will be
		'skewed, but at least the application won't crash.
		
		isColumnFiltered = True
		Exit Function
	End If
	'===================================================================================================================================

EndOfRoutine:
Exit Function
ErrorRoutine:
If ErrorHandler (GetThreadInfo (LSI_THREAD_PROC), GetThreadInfo (LSI_THREAD_CALLPROC)) = ERRORHANDLER_TOP_OF_STACK Then
Resume EndOfRoutine
End If
End Function

Good morning Torsten,

thanks a lot for you reply and its very kind of you to show us the code of your 'isColumnFiltered' method. Some of @'s I indeed did not verify in my class. Will add them now, thanks to you.

But there are even more exceptions than those @commands. If you have a column in which you change the color (fixed or calculated) for the following columns, than one usually declares it hidden and ... it will appear in NotesEntry.ColumnValues in its own column containing a multi-value color code. Good indeed for exporting with color codes, but a bit unexpected as it should be hidden. Same applies for hidden sorted columns. used to display with a different sort order. These columns also appear in the viewentries column array although declared hidden. And there are even more exceptions. Thats why I think it would be great if HCL could give us an overview of the rules, which define which columns can be found in the NoteViewEntry.ColumnValues property and which not.

Somehow I even think it would be better to have all view columns in the ViewEntry. Even if empty because they contain those @commands, but the column order would fit perfectly to what one finds in the NotesView.Columns. Then one can decide what to export and what not and the column order fits.

Jochen "Joe" Herrmann

The RULE which columns are in column values is clearly stated in documentation (I linked it above): Constants and special formulae are NOT there... If a column is hidden or not does NOT play any role here.

Therefor my code does NOT acocunt for isHidden- Property of column. Just add that as another filter to the function wherever you want and it will easily filter out hidden columns like this:

 ...
 If varTestColumn.isHidden then
    isColumnFiltered = True
    Exit Function
 End If
 ...

The "tricky" thing with color columns:

If your Formula looks something like

-1: -1: -1

then this most probaly will count as "Constant": The column will not appear in the column values.

If your Formula looks like:

@If( x = "1"; 255 : 0 : 0; -1 : -1: -1 )

then it WILL appear in the column values... So checking the "isHidden"- Property might be essential in your approach.

That's right. You can count on the Hiddden Property if it concerns the view, the UI.

But you can not count on them, if its for the NotesEntry.Columnvalues. Some Columns appear even if they should be hidden. That's my main problem right now.

Yes, and that is what my function is all about: It tells you, if a given column is in the columnvalues...

Lets say you have 5 columns:

Sum Column:

Formula: 1, display Sum, hide detail
Hidden: No

Doc Number column:

Formula: @DocNumber
Hideen: No

Color Column

Formula: @If( Status = "BAD"; 255: 0 : 0; -1 : -1 : -1 )
Hidden: Yes

Title Column:

Formula: Subject
Hidden: No

Color "End" Column:

Formula: -1 : -1 : -1
Hidden: Yes

Then NotesView.Columns will give you 5 columns.

BUT: NotesViewEntry.ColumnValues will only contain 2 Values: The Color Column (despite being hidden) and the subject column. It will NOT contains Sum (Constant) and Doc Number (Special Formula). And it will NOT contain Color End (because Constant, not because hidden)

You want to know in advance which columns the ColumnValues will return.

So you have to get the view, get ALL Columns via Columns- Property and use my function

This might look like this:

Dim columnHeaders() as String
Dim columnFrontendVisible() as Boolean
Dim i as Integer
Forall column in currentView.Columns
  If not isColumnFiltered( column ) then
    Redim Preserve columnHeaders(i)
    columnHeaders(i) = column.Title
    Redim Preserve columnFrontendVisible(i)
    columnFrontendVisible(i) = column.isHidden
    i = i + 1
  End If
End Forall

After that code you know EXACTLY how many values your "ColumnValues" of view entry will return and you know which Column Title belongs to which value. AND you know, if the column is intended to be hidden or not...

When you now cycle through column values of NotesViewEntry you just need to check the array columnFrontendVisible with the same index to decide if you want to export the column or not...

You can even export the columnHeaders- Array in advance to get a heading row in your export...

Yep, that would indeed also cover the exception of color columns.
But lets have a look at this case, something I got presented by a user last week:


View
Column 1

Title Scheme
Hidden no
Sorted yes
Categorized yes
Formula FieldScheme

Column 2

Title Sort Criteria
Hidden yes
Sorted yes
Categorized no
Formula @if(Status="Open";100;
Status="Checked";200;
Status="Authorized";300; 400)

Column 3

Titel Assistant
Hidden no
Sorted yes
Categorized yes
Formula FieldAssistant

etc. ... ...

One would assume that only 2 columns would be displayed, which is the case and thus also would expect only 2 columns in the NotesViewEntry.ColumnValues.

But instead you will have to detect that Column 2 in fact has a representation in that array at the 2. position. So this is an example for another exception that needs to be handled with extra code.

Are there more exceptions ?


Kind Regards

Jochen "Joe" Herrmann

You need to understand that "Hidden = yes" does not have ANY influence on the presence in Columnvalues. NEVER.

The only way to determine if a value is in ColumnValues is a function as posted.

It is YOUR duty as developer that the export matches the expectations of the user who only expects visible columns to be exported...

So your example is in no way a different case and it is NO exception.