I am updating user status of generating a report on to google sheets, when the status is updated onto google sheet, would like to get the response back, the main thread has to wait until the response is received.. On the main thread, after web1.Get, A record will be inserted onto the SQLDB table with status PENDING, after web1.Get method, there will be a delayed loop on sqldb record status for SUCCESSS, if the loop ends without any response, then the process is stopped. At Web1.Gottext, when the response received, the same is updated onto a record in sqldb with Success..
I just want to know if the approach is OK? is there a beter way of doing?
Also, for some reason I'm not getting the gottext event fired, even when google sheets updation is succssful, however the response is not getting received into web1.gottext.. I have given the block images and my google app script..
I tested the app script url directly onto web browser, it appends the record onto google sheet and gets the response text back.. However from my MIT app, the record is appended onto google sheets, but the web1.gottext is never called..
Thank you..
Google app script:
function addUser(e, sheet) {
var id = e.parameter.Id;
var month = e.parameter.Month;
sheet.appendRow([id, month]);
}
function addHistoryStatus(e, sheet) {
if (e.parameter.Status=="Restarted"){
sheet.appendRow([e.parameter.HealerId, e.parameter.Month, e.parameter.Status, e.parameter.OldHealerId]);
} else {
sheet.appendRow([e.parameter.HealerId, e.parameter.Month, e.parameter.Status]);
}
}
function addMonthlyReportRow(e, sheet) {
sheet.appendRow([e.parameter.HealerID, e.parameter.HealeeID, e.parameter.Name, e.parameter.Age, e.parameter.Gender, e.parameter.TreatmentDate, e.parameter.Symptoms, e.parameter.ACUPoint, e.parameter.Month]);
}
function doGet(e) {
// var academySheets = SpreadsheetApp.openById("1gHwc-U83KoUW-LNKONHrNe6Vx5hnZ0uPcDsxA3xGEEY");
var academySheets = SpreadsheetApp.openByUrl("https://docs.google.com/spreadsheets/d/1gHwc-U83KoUW-LNKONHrNe6Vx5hnZ0uPcDsxA3xGEEY/edit#gid=0");
var statusSheet = academySheets.getSheetByName("HealerReportStatus");
var historySheet = academySheets.getSheetByName("MonthlyReportHistory");
var method = e.parameter.Method;
if (method == "addUser") {
addUser(e, statusSheet);
return ContentService.createTextOutput("SuccessAddUser");
} if (method == "addHistoryStatus") {
addHistoryStatus(e, historySheet);
return ContentService.createTextOutput("SuccessAddStatus");
}
}
function doPost(e) {
// var academySheets = SpreadsheetApp.openById("1gHwc-U83KoUW-LNKONHrNe6Vx5hnZ0uPcDsxA3xGEEY");
var academySheets = SpreadsheetApp.openByUrl("https://docs.google.com/spreadsheets/d/1gHwc-U83KoUW-LNKONHrNe6Vx5hnZ0uPcDsxA3xGEEY/edit#gid=0");
var statusSheet = academySheets.getSheetByName("HealerReportStatus");
var historySheet = academySheets.getSheetByName("MonthlyReportHistory");
var method = e.parameter.Method;
if (method == "addUser") {
addUser(e, statusSheet);
return ContentService.createTextOutput("SuccessAddUser");
} if (method == "addHistoryStatus") {
addHistoryStatus(e, historySheet);
return ContentService.createTextOutput("SuccessAddStatus");
}
}