[英]How to solve execution time issue of AppScripts for non-G suite users?
I have an attendance system which is working fine for G suite users (execution time is 30 minutes) but I want to make it running for all gmail users (execution time 6 minutes).我有一个对 G Suite 用户运行良好的考勤系统(执行时间为 30 分钟),但我想让它为所有 gmail 用户运行(执行时间为 6 分钟)。 When a teacher presses a specific menu at my Google Sheets page, it allows students to report their attendance from an Android App to Google Sheet for 10 minutes.
当老师在我的 Google 表格页面上按下特定菜单时,它允许学生从 Android 应用程序向 Google 表格报告他们的出勤情况 10 分钟。
The whole code is working fine for G Suite Users but I want to make it for all Gmail users.
整个代码适用于 G Suite 用户,但我想为所有 Gmail 用户制作它。 I tried to execute it from a regular Gmail but it shows Timed Out at the end.
我尝试从常规 Gmail 执行它,但最后显示超时。
I have the following two lines of code for students to have 10 minutes to respond:我有以下两行代码让学生有 10 分钟的时间做出回应:
function refreshSheet(){
//Few other lines of codes are here
var val = dashboard.getRange("C6").getValue(); //C6 is a dropdown list in Sheets of "Start 1-Period" and "Start 2-Period"
if (val == "Start 1-Period"){ ScriptApp.newTrigger("onePeriod").timeBased().after(10*60*1000).create();}
if (val == "Start 2-Period"){ ScriptApp.newTrigger("twoPeriod").timeBased().after(10*60*1000).create();}
//These few lines of codes below within the refreshSheet() should be executed after the above called trigger and its function execution.
for (var i=0; i<students.length; i++) {
if (students[i][0] !== '') ss.removeEditor(students[i][0].toString());
}
protectionm.remove();
SpreadsheetApp.flush();
}
function onePeriod(){}
function twoPeriod(){}
I reviewed few posts here but none of them is working for me.我在这里查看了一些帖子,但没有一个对我有用。 How can I solve it?
我该如何解决?
If you deploy your script as a WebApp , you can execute it as "You" - that is the user from a GSuite domain who has an execution limit of 30 min.如果您将脚本部署为WebApp ,则可以以“您”的身份执行它 - 即来自 GSuite 域的用户,执行限制为 30 分钟。
Design your script in a different way.以不同的方式设计您的脚本。
Utilities.sleep()
, incorporate a time-driven triggerUtilities.sleep()
等待 10 分钟,不如合并一个时间驱动的触发器 Sample:样本:
function myFirstFunction(){
// do something
//now set-up the trigger:
ScriptApp.newTrigger("mySecondFunction").timeBased().after(10*60*1000).create();
}
// will be called after the amount of seconds specified in `after()`
function mySecondFunction(){
//now implement the rest of your code
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.