How can I pause the execution of code in google script until the entire spreadsheet gets updated?

为君一笑 提交于 2019-11-28 11:01:00

问题


I have a spreadsheet with lots of data and formulae. I am importing a particular cell value from spreadsheet into the google script. However since the cell is not updated with a recent revision, the script is taking the previous value. For now I have given "sleep" in script to temporarily stop the script from running so as to wait for the spreadsheet to get updated. I am not sure if the time that gave in sleep is sufficient in future with the data in spreadsheet increasing continuously.

I would like to know if there is a way to check the status of spreadsheet (updated? updating? etc). I will only run the script when the spreadsheet is updated.

Any help will be highly appreciated. This is the last issue that I reckon could be to finish my task after being struggled in logic, code, triggers etc.


回答1:


As Anees mentioned in the comments, the flush() command is what you are looking for.

SpreadsheetApp.flush();

https://developers.google.com/apps-script/reference/spreadsheet/spreadsheet-app#flush()



来源:https://stackoverflow.com/questions/26925055/how-can-i-pause-the-execution-of-code-in-google-script-until-the-entire-spreadsh

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!