【google apps scriptのwebアプリケーションの定期実行】
google apps script(GAS)でwebアプリケーション(温度管理システム)を作っています。コードは以下のようになっています。
定期実行する方法を教えて頂きたいです。
code.gs
gs
1function doGet() { 2 var htmlOutput = HtmlService.createTemplateFromFile("index").evaluate(); 3 htmlOutput.setTitle('温度管理システム'); 4 return htmlOutput; 5} 6 7//スプレッドシートからデータを取得 [[日付][時間][室温][湿度][水温]] 8function data() { 9 var sheet = SpreadsheetApp.openById("**SpreadSheetURL**").getSheets()[0]; 10 var LastRow = sheet.getDataRange().getLastRow(); 11 var data = sheet.getRange(LastRow, 1, 1, 5).getValues(); 12 return data; 13}
index.html
html
1<!DOCTYPE html> 2<html> 3 <head> 4 <base target="_top"> 5 </head> 6 <script> 7 function onSuccess(data) { 8 var div = document.getElementById('output'); 9 div.innerHTML = data[0][2]; 10 } 11 google.script.run.withSuccessHandler(onSuccess).data(); 12 </script> 13 14 <body> 15 <div id="output"></div> 16 </body> 17</html>
これで、画面に室温は画面に表示されます。
1分置きにスプレッドシートから室温を取得して表示させたいのですが、どう記述して良いのかが分かりません。
よろしくお願いします。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/01/04 20:57