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