Answer the question
In order to leave comments, you need to log in
How to run 10-15 functions sequentially in google apps script?
Best day friends!
I wrote a script that requests a list of orders from sales representatives from the service.
I have 10 projects, they will continue to grow, plus it may be that some queries can take more than 5 minutes (this is the time that Google gives to download data from external sources, but this question is for another topic)
I have such a problem. I hang a trigger on functions, but for some reason only 3-4 of them are executed, and the rest are not loaded.
function addTriggers (){
ScriptApp.newTrigger("startUpdate").timeBased().everyHours(6).create();
}
function startUpdate(){
danon();
mars();
curren1();
curren2();
vilma();
seitek();
radost();
rolls();
lysse();
}
function addTriggers () {
ScriptApp.newTrigger("danon").timeBased().everyHours(6).create();
ScriptApp.newTrigger("mars").timeBased().everyHours(6).create();
ScriptApp.newTrigger("seitek").timeBased().everyHours(6).create();
}
Answer the question
In order to leave comments, you need to log in
With some degree of probability, we can assume that this will work
/**
*
*/
const SETTINGS = Object.freeze({
fns: [
'danon',
'mars',
'curren1',
'curren2',
'vilma',
'seitek',
'radost',
'rolls',
'lysse',
],
});
/**
*
*/
function addTriggers() {
ScriptApp.getProjectTriggers().forEach((trigger) => {
if (
trigger.getEventType() === ScriptApp.EventType.CLOCK &&
SETTINGS.fns.includes(trigger.getHandlerFunction())
) {
ScriptApp.deleteTrigger(trigger);
}
});
SETTINGS.fns.forEach((fn) =>
ScriptApp.newTrigger(fn).timeBased().everyHours(6).create()
);
}
Maybe the third or fourth function crashes with an error, and therefore the execution does not go further?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question