Write, Bureaucrats, Administrators
4,332
edits
mNo edit summary |
mNo edit summary |
||
Line 212: | Line 212: | ||
===== Previous value of another field ===== | ===== Previous value of another field ===== | ||
There is a library containing the records of | There is a library containing the records of daily walks or use of a car or bicycle. The library has a StartingMileage field and a Mileage field. When an entry is created, the field StartMileage must get data from the field Mileage in the previous entry. | ||
<source lang="javascript" line> | <source lang="javascript" line> | ||
Line 222: | Line 222: | ||
</source> | </source> | ||
# Get the current library | # Get the current library — lib() — and a list of entries. | ||
# Check that the list is not empty entries | # Check that the list is not empty of entries; otherwise stop the script, so we do not have a previous entry. | ||
# | # Entries list is sorted from newest to oldest, respectively, the previous record is at the beginning of the list with an index value of 0. Get the Mileage field from the previous entry. | ||
# We set the value of the field Mileage from the previous | # We set the value of the field Mileage from the previous entry as the default value for the field StartMileage. | ||
The script must be set for action Creating and recording phase opening of the | The script must be set for action ''Creating and recording phase opening of the card''. | ||
===== Beginning the next day ===== | ===== Beginning the next day ===== |