Let's say I have a google site. On the site is a gadget to a spreadsheet. I want the gadget to show one specific row from the spreadsheet based on the username of the person viewing the site. Is this possible with GAS?
Update:
function onOpen() {
var ss = SpreadsheetApp.openById("abcdefg123456789");
var first = ss.getSheetByName("first");
var maxRows = first.getMaxRows();
var email = Session.getActiveUser().getEmail();
//show all the rows
first.showRows(1, maxRows);
var data = first.getRange('A:A').getValues();
//iterate over all rows
for (var i = 0; i < data.length; i++) {
if (data[i][0] !== email) {
first.hideRows(i + 1);
}
if (data[i][0] === "") {
return;
}
}
}
The issue with this code, or maybe it's an issue with GAS, is I can't get it to run on sites. I linked this code to a spreadsheet and it does what it's supposed to when I open it (hides every row that doesn't have my email address). However, if I link the same spreadsheet to a google site, the code does not seem to run and the windows will still show all the other rows.