我可以在app脚本中运行doget(e)。但我想在同一个脚本中运行doget(e)和dopost(e)。我编写了两个函数并部署为web应用程序,但我只能运行doget( e),为什么不掺杂(e)。
function **doGet(e)**
{
Logger.log("The value of mail id is" + e.parameter.umailid);
var answer = (e.parameter.approval == 'true') ? 'approved.All the best' : 'not approved.Try for the next event';
var sub="OD Information";
var Regno=e.parameter.regno;
var Name=e.parameter.n;
var CollegeName=e.parameter.cn;
var EventParticipation=e.parameter.ep;
var date=e.parameter.d;
var message = "<p>" + "<b>Register No: </b> " + Regno + "</p>"
+ "<p>" + "<b>Name of the student: </b> " + Name + "</p>"
+ "<p>" + "<b> Attending at </b> " + CollegeName + "</p>"
+ "<p>" + "<b>Type of Event </b> " + EventParticipation +"</p>"
+ "<p>" + "<b> Date </b> " + date + "</p>"
+"<p>" + Name +"'s OD is " + answer + "</p>";
var app = UiApp.createApplication();
app.add(app.createHTML('<h2>An email was sent to ' +e.parameter.umailid+' saying: '+ answer + '</h2>'))
return app
}
功能 doPost(e) {
var ss = SpreadsheetApp.openById(ScriptProperties.getProperty('active'));
var sheet = ss.getSheetByName("DATA");
var headers = sheet.getRange(1, 1, 1, sheet.getLastColumn()).getValues()[0]; //read headers
var nextRow = sheet.getLastRow(); // get next row
var cell = sheet.getRange('a3');
var col = 0;
for (i in headers){ // loop through the headers and if a parameter name matches the header name insert the value
if (headers[i] == "Timestamp"){
val = new Date();
} else {
val = e.parameter[headers[i]];
}
cell.offset(nextRow, col).setValue(val);
col++;
}
}