VA FileMan V. 22.2 Programmer Manual Banner


 

Main Chapter Getting Started Manual Advanced User Manual

Trigger Cross-References


Triggers for Different Files

A trigger can also update a field in a file different than the one in which the edited field exists. To illustrate this, the previous example from the "Trigger on the Same File" section is extended to show how a separate (fictitious) MONITOR file could be updated whenever a patient name is added or changed.

First, define this (fictitious) MONITOR file using the Modify File Attributes [DIMODIFY] option. The (fictitious) MONITOR file's NAME field contains the same value as the NAME field in the PATIENT (#2) file. A TIME field should be defined as a DATA TYPE field of DATE/TIME; this field contains the time the NAME field in the PATIENT (#2) file was added or changed. Use the Cross-Reference A Field [DIXREF] option on the Utility Functions [DIUTILITY] menu to set up the trigger.

Figure 414: Trigger Cross-References—Sample Dialog to Create a Trigger Cross-reference on a Field

    Select UTILITY OPTION: CROSS-REFERENCE A FIELD <Enter>

    MODIFY WHAT FILE: PATIENT <Enter>
    Select FIELD: NAME <Enter>

    CURRENT CROSS-REFERENCES:
           1    REGULAR 'B' INDEX OF FILE
           2    TRIGGER OF THE 'DATE NAME CHANGED' FIELD OF THE PATIENT
                       FILE
    Choose E (Edit)/D (Delete)/C (Create): CREATE <Enter>
    WANT TO CREATE A NEW CROSS-REFERENCE FOR THIS FIELD? NO// YES <Enter>
    CROSS-REFERENCE NUMBER: 3// <Enter>
    Select TYPE OF INDEXING: REGULAR// TRIGGER <Enter>

    WHEN THE 'NAME' field (#.01) OF THE 'PATIENT' File (#2) IS CHANGED,
    WHAT FIELD SHOULD BE 'TRIGGERED: NAME:MONITOR:TIME <Enter>
    DO YOU WANT TO PERMIT ADDING A NEW 'MONITOR' ENTRY? NO// Y <Enter> (YES)
    WELL THEN, DO YOU WANT TO **FORCE** ADDING A NEW ENTRY
          EVERY TIME? NO// Y <Enter> (YES)
      ...OK

    --- SET LOGIC ---

    IN ANSWERING THE FOLLOWING QUESTION, 'TIME'
     CAN BE USED TO REFER TO THE EXISTING TRIGGERED FIELD VALUE.
    PLEASE ENTER AN EXPRESSION WHICH WILL BECOME THE
     VALUE OF THE 'TIME' field (#1 ) OF THE 'MONITOR' File (#16001)
     WHENEVER 'NAME' IS ENTERED OR CHANGED: NOW <Enter>

    DO YOU WANT TO MAKE THE SETTING OF 'TIME' CONDITIONAL? NO// <Enter> (NO)

    --- KILL LOGIC ---

    IN ANSWERING THE FOLLOWING QUESTION, 'TIME'
      CAN BE USED TO REFER TO THE EXISTING TRIGGERED FIELD VALUE.
      NOTE: 'OLD NAME' CAN BE USED TO REFER TO THE VALUE OF
      THE NAME FIELD BEFORE ITS CHANGE OR DELETION.
    PLEASE ENTER AN EXPRESSION WHICH WILL BECOME THE VALUE OF
      THE 'TIME' field (#1) OF THE 'MONITOR' File (#16001)
      WHENEVER 'NAME' IS CHANGED OR DELETED: @
    ARE YOU SURE YOU WANT TO 'ADD A NEW ENTRY' WHEN THIS
      KILL LOGIC OCCURS? NO// Y <Enter> (YES)

    DO YOU WANT TO MAKE THE DELETING OF 'TIME' CONDITIONAL? NO// <Enter> (NO)

    WANT TO PROTECT THE 'TIME' FIELD, SO THAT
    IT CAN'T BE CHANGED BY THE 'ENTER & EDIT' ROUTINE? NO// <Enter> (NO)
    NO-DELETION MESSAGE: <Enter>
    DESCRIPTION:

    1>The TIME field of the Monitor file is triggered whenever
    2>the NAME field of the Patient file is entered or changed. The
    3>new value=NOW. A new entry in the Monitor file is created
    4>at the same time. If the NAME field in the Patient file is
    5>deleted, TIME is deleted.
    6><Enter>

    ...CROSS-REFERENCE IS SET

    DO YOU WANT TO RUN THE CROSS-REFERENCE FOR EXISTING ENTRIES NOW? NO// <Enter> (NO)

This example (Figure 414) shows the extended pointer syntax used to specify a field in another file. The patient's NAME is used as a lookup value in the (fictitious) MONITOR file. A new (fictitious) MONITOR file entry is created by the trigger. In a sense, this trigger really updates two fields in the (fictitious) MONITOR file, NAME, and TIME.

An alternative extended POINTER syntax is NAME IN MONITOR FILE:TIME. This syntax is exactly equivalent to NAME:MONITOR:TIME and can better express the meaning of the extended syntax if you are a new user.

NOTE: The at-sign (@) indicates that a field is to be deleted by the trigger.

 


Reviewed/Updated: May 2026