Write, Bureaucrats, Administrators
4,332
edits
mNo edit summary |
mNo edit summary |
||
Line 207: | Line 207: | ||
<source lang="javascript" line> | <source lang="javascript" line> | ||
var entries = lib().entries(); // Get the current library and an array of its entries | var entries = lib().entries(); // Get the current library and an array of its entries | ||
if (entries.length > 0) { // Check that the array is not empty; otherwise exit, since there is no previous entry. | if (entries.length > 0) { // Check that the array is not empty; otherwise exit, | ||
prevMileage = entries[0].field("Mileage"); // The array is sorted from newest to oldest, so the newest entry already in the array will be on top with index of 0. | // since there is no previous entry. | ||
prevMileage = entries[0].field("Mileage"); // The array is sorted from newest to oldest, | |||
// so the newest entry already in the array will be on top with index of 0. | |||
entryDefault().set("StartMileage" , prevMileage ) // Set the value of the field Mileage from the previous entry as the default value for the field StartMileage. | entryDefault().set("StartMileage" , prevMileage ) // Set the value of the field Mileage from the previous entry as the default value for the field StartMileage. | ||
} | } |