Fields

A formula has access to the fields in the document being processed. The name and type of each field is as specified in the database design.

Data types

Data types must be correct for the operation or @function being performed. For example, if TotalValue is a number field, you cannot display it directly with @Prompt because @Prompt requires a text argument. You must first convert the argument with @Text:

@Prompt([OK]; "Value of MyNumber"; @Text(TotalValue));

Rich text fields

You can convert rich text fields to plain text with @Text as shown:

plainText := @Text(Body);

Attachments and formatting, except for tabs and spaces, are lost.

Note: Conversion of rich text is new with Release 6.

You can also use @Abstract to convert rich text fields to plain text as shown:

plainText := @Abstract([TryFit]; 100; ""; "Body");

Lists

Lists are fields that contain multiple values. Certain @functions and operators deal specifically with lists. For example, if Locations is a field that allows multiple values, the following statement returns the number of values in the list:

@Elements(Locations)

Field values

The value of a field is as specified in the document when a formula starts. The formula can modify the value of a field unless prohibited by access control. You must use the FIELD reserved word to modify a field -- otherwise, the variable is treated as a temporary variable. The FIELD reserved word can also be used to create a new field in the current document. The following formula writes a value to the text field Subject.

FIELD Subject := "No Subject"

Null fields

A null field is equivalent to the text constant "" (empty quotation marks). The following example tests the field named Subject in the current document. If the value of Subject is null, it is reset to "No Subject." Otherwise, its value does not change.

FIELD Subject := @If(Subject=""; "No Subject"; Subject)

Since "" is a text constant, you should avoid its use in non-text fields. In particular, editable non-text fields should use a default formula to ensure that the field contains a value of the correct type.

Deleting fields

Use @DeleteField to delete a field from a document.

FIELD BodyText := @DeleteField

Form fields

If the form used to create a document is not stored in the document, a field named Form is available and contains the name of the form. If the form is stored in the document, fields named $TITLE, $Info, $WindowTitle (if the design specifies a window title), and $Body are available. $TITLE contains the name of the form. The following example, which works in a button or hotspot, displays the name of the form used to create the current document.

@Prompt([OK]; "Form"; @If(@IsAvailable(Form); Form; $TITLE))

Choose File - Document Properties, and select Fields to see what fields are in a document.

You can remove a form stored in a document by deleting $TITLE, $Info, $WindowTitle, and $Body. You must then create a Form field and place in it the name of a form in the database. The following formula, which works as an agent, removes the form Travel Request stored in the current document and replaces it with the database form Travel Arrangements.

SELECT $TITLE ="Travel Request";
FIELD $TITLE := @DeleteField;
FIELD $Info := @DeleteField;
FIELD $WindowTitle := @DeleteField;
FIELD $Body := @DeleteField;
FIELD Form := "Travel Arrangements"