Home > Software design >  Google Apps Script: The code is working as intended, but the time to complete is quite long. How can
Google Apps Script: The code is working as intended, but the time to complete is quite long. How can

Time:11-10

I am building a Google Sheet to act as a workflow of sorts, where each sheet is a stage of the work and upon changing a checkbox Boolean to True the row is moved to the next stage. I also have it set to reverse this process by changing the same Boolean to False.

This appears to be working as intended, and I can move any row to the next stage or send it back. The only downside is that it takes between 1.8s - 3.2s for this operation to take place. This wouldn't be an issue except that if I change one checkbox to True and then, before it has completed the operation, change a second row's checkbox to True, it doesn't run for that second instance because it is still trying to complete the first one. You can imagine that waiting 3 seconds between each operation is not ideal.

I assume that while my script works, it is poorly optimized with a lot of hardcoded variables. I have only done a little work with apps script and am learning, so I am looking as much for understanding and guidance as I am to fixing this issue. I appreciate any help offered, it will help me learn how to tackle the next problem!

Here is my code, if providing anything else is helpful just let me know:

Also, here is a link to a Copy spreadsheet in case you wanted to test what I have so far: enter image description here

Reference:

  • Related