Editable and computed fields

You choose whether a field is editable or computed in the field properties box, when you create the field. If a field is editable, a user can enter or change the value of the field. If a field is computed, a formula calculates the field value. Users can't change the values in a computed field. Number, date/time, authors, readers, and names fields are usually computed. Text, rich text, and choice list fields are usually editable.

Writing field formulas

Use the Reference tab in the Programmer's pane to access the list of fields, @commands, and @functions. You can use the Reference list as a shortcut for looking up @functions and @commands, and for pasting them into the formula.

Computed field formulas

Computed fields are used to automatically enter data, such as the author's name or the date, in a field. You can have more than one computed field on a form. Computed fields require formulas to supply their values. For example, you use a computed field to assign a creation date to a document. Computed fields are normally recalculated when users

create documents

choose View - Refresh Fields

press F9

or save documents.

All types of computed fields are only calculated when the user has the document open on-screen. If an agent updates the document, computed fields are not automatically updated. To recalculate formulas when the document is not being edited, see NotesDocument.ComputeWithForm and @Command([ViewRefreshFields]).

Selecting the field property "Compute after validation" is useful when a field is dependent on values in other fields and you want to be sure that the calculation occurs after those fields have been validated.

When it's important for users to see results as they proceed, you can force each field to be calculated as it's filled in by selecting the form property "Automatically refresh fields." This is useful when fields at the end of the form are dependent on field values at the beginning. Be aware that this property can slow down document display time if the form has many computed fields.

There are three types of computed fields:

Type of computed field

Formula calculates

Computed

A computed field formula calculates each time a user creates, saves, or refreshes a document. The field is not refreshed when the user opens the document, even in edit mode.

Computed when composed

A computed-when-composed field formula calculates only once: when the user first creates the document. Use this type of formula in a field to preserve information about the origin of a document, such as the creation date or original author, or to create a field whose original value never changes, such as a document sequence number.

Computed for display

A computed-for-display field formula recalculates each time a user opens or saves a document. Use this type of formula in a field to display information that is relevant only to the immediate session, such as the current time or the results of calculations that you don't need to save. The field value exists during the current session only and is not stored. You cannot display the contents of a computed-for-display field in a view.

To create a formula for the value of a computed field

  1. Select any type of computed field.
  2. Select Value from the Objects tab of the Info List.
  3. Write a formula, a field name, or a text string in quotation marks in the Script area of the Programmer's pane.
  4. Click the green check mark to verify and save the formula.
  5. (Optional, for computed or computed-when-displayed fields) To delay computing until after validation formulas run, choose Design - Field Properties and select "Compute after validation" on the Field Info tab.
  6. (Optional) To recalculate field values while users edit a document, click the form and choose Design - Form Properties, click the Form Info tab, and select "Automatically refresh fields."
    Note: Automatically refreshing fields can slow down document display time. A faster alternative is to write a LotusScript® field event to recalculate the document or update other fields when users move from a specific field.