Step 4. Code Fragment Virtual Fields
REP008 - Virtual Fields
In this step you will use a Code Fragment derivation to:
- Assign the length of the Notes field to the iiiNoteLength virtual field and
- To set the value of the iiiEmployYears fields to be the number of years the employee has been with the company.
1. Select the iiiNoteLength field in the list of .
2. In the
tab, enter the following:Virtual field type |
Code Fragment |
Derive value when record is read |
Select for Yes |
Virtual Field Derivation |
#iiiNoteLength := #iiiEmployNotes.CurChars Replace iii with your initials. |
Your
tab should now look like this:
The code fragment uses an RDMLX intrinsic method CurChars to determine the number of characters in the iiiEmployNotes field and assigns the result to the iiiNoteLength field.
3. The iiiNoteLength field will now be listed under the
.Next you will set the iiiEmployYears field to show how many years an employee has worked for the company based on the Start Date field.
4. Select the iiiEmployYears field in the list of .
5. In the
tab, enter the following:
|
Your
tab should now look like this:
The code fragment uses RDMLX 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 file and ensure the compilation ends without errors.