Hello all,
Im currently just learning Javascript and making an App for my Club. One of the members has asked for a page which will display all members that have checked in that day.
So far this is the code i have, but its returning the error "The script completed but the return value is not the supported type" But when it doesnt find any Row with todays date. it returns my Else statement of "no entries found"
Here is what i have coded so far below:
<pre>// Commences Check input
function check(date){
var in_time = Utilities.formatDate(new Date(), 'Etc/GMT', 'yyyy-MM-dd');
var successId = 0;
var rows = dailySheet.getDataRange().getValues();
var filteredRows = rows.filter(function(row){
if (row[4] === in_time) {
successId = Number(successId)+1;
return row;
}
})
if(successId == 1){
var i;
for (i = 0; i < filteredRows.length; i++) {
return ContentService.createTextOutput(filteredRows[i][1]+" "+filteredRows[i][2]).setMimeType(ContentService.MimeType.TEXT)+ "<br>";
}
}
else{
return ContentService.createTextOutput("No Entries Found").setMimeType(ContentService.MimeType.TEXT);
}
}
This is what the excel sheet looks like.
https://imgur.com/ubah3eM
No entries Found.
https://imgur.com/ABgMVCG
Error.
https://imgur.com/MiBpG5e
What I have tried:
i have tried recoding it but to no avail.
This works but only when there is one entry of todays date, when there are more than one entry it displays No entries found instead of the multiply entries.
var ss = SpreadsheetApp.openByUrl("https://docs.");
var dailySheet = ss.getSheetByName("daily_attendance");
var memberSheet = ss.getSheetByName("membership");
function doPost(e){
var action = e.parameter.action;
if(action == "check"){
return check(e);
}
}
function check(e){
var in_time = Utilities.formatDate(new Date(), 'Etc/GMT', 'yyyy-MM-dd');
var successId = 0;
var rows = dailySheet.getDataRange().getValues();
var filteredRows = rows.filter(function(row){
if (row[4] === in_time) {
successId = Number(successId)+1;
return row;
}
});
if(successId == 1){
return ContentService.createTextOutput(filteredRows[0][2]+" "+filteredRows[0][3]).setMimeType(ContentService.MimeType.TEXT);
}
else{
return ContentService.createTextOutput("No Entries Found").setMimeType(ContentService.MimeType.TEXT);
}
}