I am trying to create a simple script with a function to create new sheets and a main function to email those sheets. When I try to call the function to create sheets inside
Google Apps Script apply changes made on Google Sheet in batches:
Scripts commonly need to read in data from a spreadsheet, perform calculations, and then write out the results of the data to a spreadsheet. Google Apps Script already has some built-in optimization, such as using look-ahead caching to retrieve what a script is likely to get and write caching to save what is likely to be set.
Use SpreadsheetApp.flush() to "force" the application of the changes that your script made before sending the sheets by email.
Related