简体   繁体   English

Google Apps脚本:如何设置返回我的页面?

[英]Google Apps Script: How to set return to my page?

I'm using Google Apps Script to write values from a form to a Google Spreadsheet. 我正在使用Google Apps脚本将表单中的值写入Google Spreadsheet。

I have the form in my HTML page and its action calls the Google Apps Script to write in the sheet. 我的HTML页面中有该表单,其操作称为Google Apps脚本以将其写入工作表中。

Now I'd like to go back to my site with a flag var and show a message (Error or Complete) based on the result of the function. 现在,我想返回带有标记var的站点,并根据函数的结果显示一条消息(错误或完成)。

I know how to create and set the flag variable but I don't know how to "send" it to my page. 我知道如何创建和设置标志变量,但不知道如何将其“发送”到我的页面。 I was only able to show my flag with something like this (that's the whole function I have in GAS) 我只能用这样的东西显示我的旗帜(这就是我在GAS中拥有的全部功能)

function doPost(e){

var id = "";
var name = e.parameter['name'];
var surname = e.parameter['surname'];
var serial = e.parameter['serial'];
var eMail = e.parameter['email'];
var text = e.parameter['text'];
var date = new Date();
var ans = ""
var ctrl= "WIP";

var vals = [id, date, name, surname, serial, eMail, text, ans, flag];
var sheetObj =SpreadsheetApp.openById("myKey").getSheetByName('Requests').appendRow(vals);
return ContentService.createTextOutput(someOutput);
}

Someone knows how to do what I need? 有人知道我该怎么做吗?

Thanks a lot for your help! 非常感谢你的帮助!

S. S.

You can do something like this 你可以做这样的事情

return ContentService.createTextOutput("Complete").setMimeType(ContentService.MimeType.TEXT);

Or in case of exception return 'Error' from your catch block like this 或者在异常情况下,从您的catch块中返回“错误”,如下所示

return ContentService.createTextOutput("Error").setMimeType(ContentService.MimeType.TEXT);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM