Editable field formulas

About this task

You can write up to four formulas for each editable field:

  • The default value formula provides an initial value that the user can change. Providing a default value for an editable field ensures that the field gets filled in and often removes the need for users to enter data such as their name or the date.
  • The input translation formula modifies the contents of a field after a user fills it in -- for example, to correct typing or standardize the format. Use an input translation formula to format information entered by users -- for example, to make all entries uppercase. The result of the formula replaces what the user entered. Input translation formulas are evaluated each time a document is saved, recalculated, or refreshed.
  • The input validation formula checks the contents of a field against predefined criteria, making sure the entry meets certain requirements. For example, use an input validation formula to ensure that users fill in a required field. Input validation formulas are evaluated each time a document is saved, recalculated, or refreshed.
  • The input enabled formula enables or disable the field for input. If Input Enabled evaluates to 0, data cannot be added to the field. If it evaluates to anything else, data can be added to the field.

    Input Enabled appears in the Object list of the Programmer's Pane for all field types except rich text and rich text lite.

To create a default value or input translation formula

Procedure

  1. Create an editable field.
  2. Select Default Value or Input translation from the Object tab of the Info List.
  3. Write one of the following in the Script area of the Programmer's pane:
    • A formula
    • A field name
    • A text string in quotation marks
  4. Click the green check mark to verify and save the formula.

Results

To enter a literal text string, enclose it in quotation marks (" "). Field names don't need quotation marks.

If you select the form property "On Create: Formulas inherit values from selected document" when designing the form, use the default formula to specify the field from which this new field inherits its value. When a new document is composed with this form, the field value is copied from the document that is currently highlighted if that document contains the specified field.

An alternative to an input translation formula is to write a script for the Exiting event that verifies information.

To create an input validation formula

Procedure

  1. Create an editable field.
  2. Select the Input Validation event from the Objects tab of the Info List.
  3. Write a formula in the Script area of the Programmer's pane using @Failure and @Success.
  4. Click the green check mark to save the formula.

Results

@Failure prevents the user from saving the document until the user enters a value that meets the criteria. As part of the formula, include text that clearly indicates what is wrong and how the user can correct it.

To create an input enabled formula

Procedure

  1. Create an editable field.
  2. Select the Input Enabled event from the Objects tab of the Info List.
  3. Write a formula in the Script area of the Programmer's pane that evaluates to @True or @False.
  4. Click the green check mark to save the formula.