Creating fields that inherit values

About this task

Inheritance is the copying of field values from an existing document when composing a new document, to save time or ensure consistency between documents.

Note: There is no built-in function to synchronize the field values between the original document and the new document after creation. Inheritance only fills in initial field values. Keeping the documents synchronized if either is later edited would require custom code.

To inherit field values from a document in the Notes® client, the document must either be open in the Notes® client or highlighted in a view when composing the new document.

In web applications, the new document determines which document to inherit from based on the URL argument ParentUNID in the Domino® URL command, for example:

http://server/db.nsf/InheritanceForm?OpenForm&ParentUNID=6b87e303374b19148525639a00506656

To create a field that inherits values from another document

About this task

Create fields that inherit information from another document to save users from unnecessary typing or to keep related documents consistent. Open the form that will be used to create the new document.

Procedure

  1. Choose Design - Form Properties.
  2. In the Defaults tab, select "On Create: Formulas inherit values from selected document."
  3. Create the fields that should inherit values. New fieldnames do not have to match the fieldnames whose values they inherit.
    Note: If new fields inherit values from fields that share a name with fields on the new form, all formulas referencing the parent field must appear prior to the new field with the same name.
  4. Write a default value or computed field formula for each field using the parent document field name as the value. For example, to inherit the FullName field, use FullName as the inheriting field's formula.
    Note: The formula does not have to contain only the name of the parent field. For instance, the Subject field of a reply message might have a default formula of "Re: "+Subject.

Results

When values are inherited, the values are read from the last saved version of the document, not from the document currently displayed. Values in "Computed for display" fields can never be inherited, since these are not saved.

Formulas inherit the values of the parent document's fields. Fields do not inherit values, except through the use of formulas in their default or computed values. Using the same fieldname for a field on the new document is not sufficient to inherit the parent document's values of that field.

Inherited values from the parent document are only available while the new document is being composed. Once the new document has been created, and either saved or displayed for editing, the parent document's values are no longer available for use in formulas.

If a field on the new form shares a name with a field on the parent form, references to that fieldname in formulas preceding the field on the new form will use the parent form's field value. References to that fieldname in formulas after the field on the new form will use the new form's field value. For instance, suppose you had three fields on the new form, in this order:

OrigSubject: Computed when composed, formula Subject

Subject: Editable, default value formula "Re: " + Subject

OrigSubject2: Computed when composed, formula "Topic: " + Subject

The field OrigSubject2 will contain the text "Topic: Re: " followed by the Subject of the parent document, because it will use the value of Subject defined on the new form.

Example: Inheriting address information

About this task

In a Customer Contacts application, a Letter form uses inheritance to copy information from a Company Profile document. The Company Profile contains name and address fields (FirstName, LastName, Address) and a hidden computed field called FullName (with formula FirstName + " " + LastName).

The Letter form has an editable field Salutation whose default value formula is "Dear" + FullName, and an editable field Address whose default value formula is Address.

When Notes® client users highlight a Company Profile document in a view and choose Create - Letter, the Letter is already filled in with the recipient's address and salutation. The user can then edit these fields, if desired.

When Web users open the Company Profile document and click a button to create a Letter document, it works the same way.

Language cross-reference