Triggers: Difference between revisions

6 bytes removed ,  24 September 2016
m
no edit summary
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 the daily running of the car, bicycle or your walks. The library has StartingMileage field and Mileage.When you create a record is required in the field StartMileage enter data from the field Mileage previous record.
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 the lib () and a list of entries it records ().
# Get the current library &mdash; lib() &mdash; and a list of entries.
# Check that the list is not empty entries, otherwise stop the script, so we do not have a previous record.
# Check that the list is not empty of entries; otherwise stop the script, so we do not have a previous entry.
# Records 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 record.
# 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 record as the default value for the field StartMileage.
# 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 form.
The script must be set for action ''Creating and recording phase opening of the card''.


===== Beginning the next day =====
===== Beginning the next day =====