I am creating a Google Apps Script web app that uses Google Sheets as its backend. This web app basically allows users to track their work time (clock in for the day, clock out for lunch, clock in from lunch, & clock out for the day). Currently, I have the app reading data from the spreadsheet and displaying to an HTML table using a client side javascript call to the server side javascript, which is what actually opens the SpreadsheetApp (by URL) and retrieves the data to send back to the client side javascript for display. However, the spreadsheet has quite a few calculations that need to be performed and takes a few seconds before updating the values. My script, however, reads the initial values and doesn't wait for them to update; often leading to stale data being displayed. I've tried using SpreadsheetApp.flush()
to force the spreadsheet to finish calculating before retrieving the data in my script, however it still seems to pull the data before calculations are finished. Should I be using SpreadsheetApp.flush()
before or after opening the spreadsheet with SpreadsheetApp.openByUrl(spreadsheetURL)
? Or maybe after my call to userSpreadsheet.getSheetByName("Timecard")
? I've tried each, but to no avail.
Any help is appreciated!