AddColumn (NotesQueryResultsProcessor - LotusScript)
Defined in
Syntax
Call notesQueryResultsProcessor.AddColumn( String Name, Optional String Title, Optional String Formula, Optional Integer SortOrder, Optional Boolean Hidden, Optional Boolean Categorized)
Parameters
Name
The unique programmatic name of the column within a QueryResults Processor instance. If there is no override using the addFormula method call, the name provided is treated as a field name in each database involved in the QueryResultsProcessor object.
In JSON output, the name value used is the element name for each returned entry. Values in the name field can also specify aggregate functions. Aggregate functions require categorized columns and they return computed numerical values across sets of results within a given category. For more information, see the description of categorized. For aggregate functions requiring a name as an argument, that name can be overridden the same as any name value without the aggregate function.
Title
String. Optional. The display title of the column. Used only in generated views, the title is the UI column header.
Formula
- AddFormula Formula Language override
- Formula argument of the AddColumn method
- Use the name argument of the AddColumn method as a database field name
SortOrder
Integer. Optional. A constant indicating the direction of the sort. Default is SORT_UNORDERED. Legal values are:
SORT_UNORDERED
SORT_ASCENDING
SORT_DESCENDING
Hidden
Boolean. Optional. Specify this to sort by a column value but not return it. If true, the column cannot have a SortOrder of SORT_UNORDERED and cannot have Categorized set to True.
Categorized
Boolean. Optional. Categorized columns have a single entry returned for each unique value with entries containing that value nested under it. In JSON results, these nested entries are represented in arrays under each categorized unique value.
Multiply-occurring fields (i.e. lists) are not allowed to be categorized.
Any categorized column with a preceding uncategorized column or columns will force the creation of categorized values containing all prior uncategorized columns plus the categorized column.
Col1 | Col2 | Col3 | Col4 | Col5 | Col6 | Col7 |
categorized | categorized | categorized |
@@avg(col1)
Returns the sum all values of col1 within the current category divided by the number of documents.@@sum(col2)
Returns the sum of all values of col2 within the current category.@@max(col3)
Returns the maximum numeric value of col3 within the current category.@@min(col4)
Returns the minimum numeric value of col4 within the current category.@@count()
Returns the count of documents within the current category
Aggregate function columns must appear after the categorized column whose values control their computation. They are always SORT_UNORDERED, that is, unsorted.
1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
Col1 |
Col2 |
@@avg(col3) |
@@sum(col4) |
Col5 |
Col6 |
@@avg(col7) |
Col8 |
- a. Any non-categorized, non-aggregate columns
- b. A single categorized column
- c. Any aggregate columns (can be multiple as above)
- d. Finally, any document-level columns not taking part in categorization. That is, document detail.
Example
Set qrp = db.Createqueryresultsprocessor()
…
Call qrp.Addcolumn("sales_person", "", “”, SORT_ASCENDING, False, True)
Call qrp.AddColumn("ordno", "", “”, SORT_DESCENDING, False, False,
“order_number * 1000”)
Call qrp.AddColumn("order_origin", "", “”, SORT_UNORDERED, False, False)
Call qrp.AddColumn("partno")
Example with categories and aggregate functions
‘ First category - 2 fields making 1 categorized key value
Call qrp.AddColumn("Department", "Dept",, “$Left(dept; 10)”,
SORT_ASCENDING, False, False);
Call qrp.AddColumn("JobTitle", "Job Title ", “"SORT_ASCENDING, False, True)
‘ aggregates off the first category
Call qrp.AddColumn("@@avg(salary)", "", “”, SORT_UNORDERED, False, False)
Call qrp.AddColumn("@@sum(salary)", "", “”, SORT_UNORDERED, False, False)
‘ 2nd category - 2 field categorized key
Call qrp.AddColumn("GEO”) ‘ see shortened method form below
Call qrp.AddColumn("OU", "Organizational Unit ",””, SORT_ASCENDING, False, True)
‘ 4 aggregates off the 2nd category
Call qrp.AddColumn("@@count()", "", “”, SORT_UNORDERED, False, False)
Call qrp.AddColumn("@@avg(salary)", "", SORT_UNORDERED, False, False)
Call qrp.AddColumn("@@sum(salwithraise)", "", “”, SORT_UNORDERED, False, False)
Call qrp.AddColumn("@@avg(salwithraise)", "", “”, SORT_UNORDERED, False, False)
‘ document detail under both categories - unique to Domino
Call qrp.AddColumn("FullName", "Full Name ", “”, SORT_ASCENDING, False, False)