如何为非G套件用户解决AppScripts的执行时间问题? [英] How to solve execution time issue of AppScripts for non-G suite users?
问题描述
我有一个考勤系统,对于G套件用户(执行时间为30分钟)可以正常使用,但我想使其对所有gmail用户都可以运行(执行时间为6分钟).老师按下我的Google表格页面上的特定菜单后,学生可以在10分钟内将自己的出勤情况从Android应用报告给Google表格.
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). 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.
对于G Suite用户,整个代码都可以正常工作,但我想做到这一点适用于所有Gmail用户.我尝试从常规Gmail执行它,但是它最后显示超时.
The whole code is working fine for G Suite Users but I want to make it for all Gmail users. I tried to execute it from a regular Gmail but it shows Timed Out at the end.
我有以下两行代码,让学生有10分钟的响应时间:
I have the following two lines of code for students to have 10 minutes to respond:
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?
推荐答案
您可以执行以下两项操作:
-
如果您将脚本作为 WebApp ,您可以将其执行为您"-那是来自GSuite域的用户,其执行限制为30分钟.
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.
以其他方式设计脚本.
- 使用触发构建器
- 这意味着-结束当前功能,并指定脚本的延续(嵌入在第二个功能中)将在10分钟后开始运行.
- 之间的时间将不算作执行时间,也不会导致超时.
示例:
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
}
这篇关于如何为非G套件用户解决AppScripts的执行时间问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!