Selecting which documents display in a view

When you design a view, you can program it to show all documents or only certain documents in the database. Most databases have one view that shows all documents and other views that show a subset of documents.

The default selection formula for new views combines the SELECT statement and the @All formula into SELECT @All, which means "include all database documents in this view." To narrow down the kinds of documents the view displays, add a program that displays only particular documents. For example, in a task-tracking database, the Work in Progress view could display only those documents whose Status field does not contain "Complete." In a brainstorming database, the Design Ideas view could display all documents categorized as "Design Suggestion." Here is a selection formula that displays only documents containing new features and displays them in a What's New view:

SELECT @IsMember("01 What's new?"; View)

Choosing the type of view selection

With a view you program the document selection in the Programmer's pane. Choose "View Selection" in the Objects box, select the type of programming you want to add, and build the program in the View Selection pane.

Simple Search

Simple Search allows you to create a conditional document selection without knowing a programming language. In the InfoList of the Programmer's pane, click the Run list box and select Simple Search. Then click "Add Condition" for each selection you want to include. To delete a condition, click it and choose Edit - Delete.

By Formula

By Formula allows you to create a program for selecting documents using the @function formula language. In the Programmer's pane, click By Formula and write the formula in the Script area.

Relationships among documents

These databases are not relational. A selection formula is applied to each document separately (with two exceptions noted later). For example, you cannot select the most recent document and you cannot select a document with a value that matches a value in another document.

The two exceptions are selection formulas containing @AllDescendants and @AllChildren which let you select a response document based on whether its parent is also in the view.

For relationships you can do the following:

  • Store your data in DB2-enabled Notes® databases. See DB@ access views.
  • Write a server agent that analyzes the relationships and sets a value to identify the desired document. For example, you might write an agent that runs on new and modified documents, locates the most recent, sets Latest = "1" in that document, and deletes Latest from the current document with that setting. The selection formula SELECT Latest = "1" locates the most recent document.