Step 5. Virtual Column for Years Employed

1.  Select the iiiEmployYears field in the list of Undefined virtuals.

2.  In the Details tab, enter the following:

Virtual field type

Code Fragment

Derive value when record is read

ΓΌ Select this option


3.  In Virtual Field Derivation, add the following code:
#iiiEmployYears := #iiiStartDate.Date.Now.Difference( #iiiStartDate ) / 365

     Change the code to use your initials.

     Your Details tab should now look like this:

     The code fragment uses intrinsic methods Date and Difference to compare the date portion of the iiiStartDate field with today's date and divides the result by 365.

     All your virtual fields are now listed under Read Virtuals.

6.  Compile the table and ensure the compilation ends without errors. The compile simply needs to rebuild the OAM.