Google apps script Web应用在函数后如何更新表
好的,我在我的webapp上取得了一些进展,我最初使用以下方法获取表信息:Google apps script Web应用在函数后如何更新表,google-apps-script,web-applications,Google Apps Script,Web Applications,好的,我在我的webapp上取得了一些进展,我最初使用以下方法获取表信息: google.script.run.withSuccessHandler(buildTable).getTable(); 其功能是 function buildTable(myTable) { document.getElementById('table_id').innerHTML = myTable; } 但我有另一个函数,它可以更改表中的值(正常工作),但它不会重新运行load table函数 &
google.script.run.withSuccessHandler(buildTable).getTable();
其功能是
function buildTable(myTable) {
document.getElementById('table_id').innerHTML = myTable;
}
但我有另一个函数,它可以更改表中的值(正常工作),但它不会重新运行load table函数
<input type ="button" id="slideL" value="Advance" onclick ="google.script.run.logicAdvance(3).withSuccessHandler(updateOutput)"/>
有什么想法吗
更新:好的,我删除了日志程序调用,并添加了一个错误1,它似乎也没有运行。代码的当前版本
function updateOutput(result){
document.getElementById('ask').innerHTML = result.displayInfo;
document.getElementById('table_id').style.display ='block';
document.getElementById('ask').style.display = "none";
google.script.run.withSuccessHandler(buildTable).getTable();
}
function errorFunction (e){
document.getElementById('ask').innerHTML = e;
}
<div id="ask" style="display:block">Do you want to proceed with this idea?
<div id="choiceBox">
<input type ="button" id="slideL" value="Advance" onclick ="google.script.run.logicAdvance(3).withSuccessHandler(updateOutput).withFailureHandler(errorFunction)"/>
<input type ="button" id="declineButton" value="Decline" onclick ="finish()"/>
</div>
</div>
html中没有
记录器<代码>信息
似乎也没有定义。
改用
console.info()
。我将命令调用向后:
<input type ="button" id="slideL" value="Advance" onclick ="google.script.run
.withSuccessHandler(updateOutput)
.withFailureHandler(errorFunction)
.logicAdvance(3)"/>
修好它 也许可以在
google.script.run中添加一个.withFailureHandler(errorFunctionName)
,然后显示返回的错误?您的服务器端可能未完全成功。我收到一个奇怪的控制台错误:userCodeAppPanel:1未捕获类型错误:无法读取HTMLInputElement.onclick(userCodeAppPanel:1)上未定义的属性“withSuccessHandler”。谢谢,登录控制台帮助我找到了解决该问题的方法。
function logicAdvance(row){
var scriptProperties = PropertiesService.getScriptProperties();
scriptProperties.setProperty('row', row);
var status = ss.getRange(row,9).getValue();
var myObj ={displayValue : "none"};
if (status == 1){myObj.displayValue= "block"; return myObj;}
if (status == 4){myObj.displayValue= "block"; return myObj;}
advanceStatus(row);
return myObj;}
//- This function changes the status of the object
function advanceStatus(row){
var sh = SpreadsheetApp.openById('xx');
var ss = sh.getSheetByName("Form Responses 1");
var status = ss.getRange(row, 9);
var newStatus = parseInt(status.getValue()) + 1;
if (newStatus == 20) return;
if (newStatus == 9) return;
status.setValue(newStatus);
return;
<input type ="button" id="slideL" value="Advance" onclick ="google.script.run
.withSuccessHandler(updateOutput)
.withFailureHandler(errorFunction)
.logicAdvance(3)"/>