Hi, I have inserted a new “Seniority Date” field into Employee Table. By default it should be equal to the existing “Employment Date” field. However, it could be edited manually but should never be more than the “Employment Date”. How do I do that? Please help.[:0] Thank you.
In the Employee Table: Employment Date Field Trigger: On Validate IF Seniority Date <> 0D Then Begin IF Confirm('Do you want to update Seniority Date?',TRUE) THEN "Seniority Date" := "Employment Date"; END ELSE BEGIN "Seniority Date" := "Employment Date"; END; Seniority Date Field Trigger: On Validate If "Employment Date" = 0D Then Error('Please provide an employment date first'); IF "Seniority Date" > "Employment Date" Then Error('Seniority Date cannot be greater than Employment Date');
Additionally: You can still write the trigger code, but to backfill existing records you can write a report based on the Employee Table. In the OnAfterGetRecord trigger: IF "Seniority Date" = 0D THEN BEGIN (you may want to skip any entries that have already been made in the new field) "Seniority Date" := "Employment Date"; MODIFY; END;
This will fill in all blank Seniority Dates, then you can throw this report away and the Table trigger logic will manage it going forward.
Dear Devin! Thank you so much, it works awesome!!! [:)][:)][:)] We already have it up and running in the system (for all our 165 companies).