我在下面的 Google 脚本代码中遇到了一些问题:
当我这样做时: var Emails = e.parameter.Email; (功能自动用户)
我无法获取值,它似乎未定义,值没有从一个函数传递到另一个函数。
怎么了?
function doGet() {
var app = UiApp.createApplication();
var grid = app.createGrid(3, 2);
grid.setWidget(0, 0, app.createLabel('Informações para Login:'));
var Contactemail = app.createTextBox();
Contactemail.setName('Email');
grid.setWidget(1, 0, app.createLabel('Email:'));
grid.setWidget(1, 1, Contactemail);
var Contactpassword = app.createPasswordTextBox();
Contactemail.setName('Password');
grid.setWidget(2, 0, app.createLabel('Senha:'));
grid.setWidget(2, 1, Contactpassword);
var panel = app.createVerticalPanel();
panel.add(grid);
var button = app.createButton('Logar');
var handler = app.createServerHandler('Aut_User');
handler.addCallbackElement(grid);
button.addClickHandler(handler);
panel.add(button);
app.add(panel);
return app;
}
function getColIndexByNamelink(colName, ID) {
var sheet = SpreadsheetApp.openById(ID).getSheets()[0];
var numColumns = sheet.getLastColumn();
var row = sheet.getRange(1, 1, 1, numColumns).getValues();
for (i in row[0]) {
var name = row[0][i];
if (name == colName) {
return parseInt(i) + 1;
}
}
return -1;
}
function Aut_User(e) {
var ID = "0AqmZV_vU4x5cdFQyOFo2TlE3dkxFYi1rVUk3OUxzYWc";
var sheet = SpreadsheetApp.openById(ID).getSheets()[0];
var lastRow = sheet.getLastRow();
var Emails = e.parameter.Email; //PROBLEM HERE
//parametros da outra funcao
for (var i = 2; i < (lastRow + 1); i++) {
sheet.getRange("A4").setValue(Emails);
//conferir os dados
}
}