To quote the documentation, the 'check-field' trigger performs verification checks on a value specified for a form column, and so potentially can be very useful. In forms which are concerned with sales, the status of a given part is checked to see that the 'sellflag' is marked, i.e. the part can be sold to customers. In one specific form, no such check was performed and it was my job to define the required trigger.
There is one very important rule to remember for 'check-field' triggers: do not rely on any form variables! This is because the field has yet to be exited and so other fields have yet to receive any values. An example might help: as soon as a valid part number has been entered, other fields such as price and the internal part number itself get their values. But these fields are empty when 'check-field' is operating.
So how does one get the value of the current field? One uses the special variable :$.@. Thus the trigger which I finally wrote last night looks like this:
I use the concise syntax ('errmsg X from ...') which I discussed here.ERRMSG 9000 FROM PARTSTATS, PART WHERE PARTSTATS.PARTSTAT = PART.PARTSTAT AND PARTSTATS.SELLFLAG <> 'Y' AND PART.PARTNAME = :$.@;