Triggers: Difference between revisions

17 bytes removed ,  7 October 2016
m
no edit summary
mNo edit summary
mNo edit summary
Line 204: Line 204:


<source lang="javascript">
<source lang="javascript">
var entries = lib().entries();                  // Get the current library and an array of its entries
var entries = lib().entries();                  // Get current library & array of its entries
if (entries.length > 0) {                      // Check that the array is not empty;
if (entries.length > 0) {                      // Check that array is not empty;
                                                 // otherwise exit,
                                                 // otherwise exit,
                                                 // since there is no previous entry.
                                                 // since there is no previous entry.
prevMileage = entries[0].field("Mileage");      // The array is sorted newest to oldest,
prevMileage = entries[0].field("Mileage");      // The array is sorted newest to oldest,
                                                 // so the newest entry in the array
                                                 // so newest entry in the array
                                                 // on top with index of 0.
                                                 // on top with index of 0.
entryDefault().set("StartMileage",prevMileage); // Set value of field Mileage
entryDefault().set("StartMileage",prevMileage); // Set value of field Mileage