0

I have a few functions which apply various operations to one sheet.

Function A inserts rows and then resorts the rows after insertion.

Function B replaces cells in certain rows depending on the ID key of that row (ID is just a number in column A).

Functions A and B are triggered independently by timed triggers with no guarantee that they won't be triggered at the same time.

My concern is that Function A and B run at the same time, and while B is working, A does a resort, and therefore B replaces cells in the wrong row.

How does Google handle concurrent triggers in the same project and where the functions act on the same sheet?

Alexander Soare
  • 2,825
  • 3
  • 25
  • 53
  • 1
    Unfortunately, in my experience, it seems that when 2 functions are run by the time-driven trigger, both functions cannot be run exclusively under the default. When you want to exclusively run 2 functions, how about using Lock Service? [Ref](https://developers.google.com/apps-script/reference/lock) By this, each function is not run, simultaneously. But I'm not sure whether this is the direction you expect. So when this is not the direction you expect, I apologize. – Tanaike May 13 '20 at 08:41
  • About the usage of the lock service, I think that these threads might be useful. https://stackoverflow.com/q/34878161 and https://stackoverflow.com/q/43223774 – Tanaike May 13 '20 at 08:52
  • 1
    Another possibility would be set only one function on time trigger and call the second function from the first function. – ziganotschka May 13 '20 at 09:08

0 Answers0