Need To Retrieve A Specific Amount Of Data From Previous Entries On Gas Web App
Similar to a question I had asked previously (Check for login username and password, and then bring data from every previous entry). I have created a web app to track the working h
Solution 1:
I believe your goal as follows.
- You want to retrieve 10 values from the function
checklogin()
. - The rows of your Spreadsheet is the scending order.
In this case, how about the following modification?
From:
if (ranges.length > 0) {
obj.dateTime = ranges.flatMap(r => r.offset(0, 1, 1, 2).getDisplayValues());
return obj;
}
To:
if (ranges.length > 0) {
if (ranges.length > 10) {
ranges = ranges.splice(-10);
}
obj.date1Time = ranges.flatMap(r => r.offset(0, 1, 1, 2).getDisplayValues());
return obj;
}
- By this modification, when the length of
ranges
is over 10, the last 10 values are retrieved. - When the length of
ranges
is NOT over 10, all values are retrieved. - If you want to sort as the descending order and you want to retrieve first 10 values, please modify
ranges = ranges.splice(-10)
toranges = ranges.splice(0, 10)
.
Post a Comment for "Need To Retrieve A Specific Amount Of Data From Previous Entries On Gas Web App"