|Contents:||Main||Chapter||See Also:||Getting Started Manual||Advanced User Manual|
Adding a time and date stamp to the file whenever a particular field is updated is a simple example of a trigger. Suppose the Patient file has a date-valued field called DATE NAME CHANGED. Here is how you could put the current date and time into this field whenever the patient's NAME is entered or changed:
Select OPTION: UTILITY FUNCTIONS Select UTILITY OPTION: CROSS-REFERENCE A FIELD MODIFY WHAT FILE: PATIENT (1890 entries) Select FIELD: NAME CURRENT CROSS-REFERENCE IS REGULAR 'B' INDEX OF FILE Choose E (Edit)/D (Delete)/C (Create): CREATE WANT TO CREATE A NEW CROSS-REFERENCE FOR THIS FIELD? NO// Y (YES) CROSS-REFERENCE NUMBER: 2// Select TYPE OF INDEXING: REGULAR// TRIGGER WHEN THE NAME field (#.01) of the PATIENT File (#2) IS CHANGED, WHAT FIELD SHOULD BE 'TRIGGERED': DATE NAME CHANGED ..OK
The field to be triggered must already exist.
---- SET LOGIC ---- IN ANSWERING THE FOLLOWING QUESTION, 'DATE NAME CHANGED' CAN BE USED TO REFER TO THE EXISTING TRIGGERED FIELD VALUE. PLEASE ENTER AN EXPRESSION WHICH WILL BECOME THE VALUE OF THE DATE NAME CHANGED field (#2) OF THE 'PATIENT' File (#2) WHENEVER 'NAME' FIELD IS ENTERED OR CHANGED: NOW DO YOU WANT TO MAKE THE SETTING OF 'DATE NAME CHANGED' CONDITIONAL? NO// (NO)
If you answered YES, you can set conditions for the trigger. You will get the prompt:
ENTER AN EXPRESSION FOR THE CONDITION: --- KILL LOGIC --- IN ANSWERING THE FOLLOWING QUESTION, 'DATE NAME CHANGED' 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 'DATE NAME CHANGED' field (#2) OF THE 'PATIENT' File (#2) WHENEVER 'NAME' IS CHANGED OR DELETED: NO EFFECT
You have specified that the NAME field will trigger the DATE NAME CHANGED field (noting that the NAME field is already cross-referenced in the usual way). You have requested that the current date/time (NOW) be stuffed into the triggered field.
Since this triggering will occur whenever NAME is changed, you don't have to specify anything else that depends on the pre-existing value of NAME. When the entire patient entry is deleted, the DATE NAME CHANGED will be deleted along with the name. Thus, no KILL LOGIC is needed. The response to pressing the Enter/Return key at that prompt is "NO EFFECT".
Since you always want the trigger to take place when NAME is changed, no condition is placed on the trigger. A trigger can be setup that will only occur under specified circumstances.
WANT TO PROTECT THE 'DATE NAME CHANGED' FIELD, SO THAT IT CAN'T BE CHANGED BY THE 'ENTER & EDIT' ROUTINE? NO// YES
You specify that the only way you want the DATE NAME CHANGED field to be updated is via this trigger. No Enter or Edit File Entries option user (not even one with an @-sign) will be able to change a patient's DATE NAME CHANGED field directly.
If you enter a free text message at this prompt, this cross-reference cannot be deleted.
DESCRIPTION: 1>The DATE NAME CHANGED field will be triggered whenever the 2>NAME field is entered or updated. The triggered value will be 3>NOW. This field cannot be edited. 4>
The description will appear in a standard DD listing.
...CROSS-REFERENCE IS SET DO YOU WANT TO RUN THE CROSS-REFERENCE FOR EXISTING ENTRIES NOW? NO//
Finally, you have the option of using the new trigger to update the file. In this case, it would not be useful to put the current date and time into the DATE NAME CHANGED field for every existing entry. Thus, the NO default is accepted.
Reviewed/Updated: March 4, 2007