Posts

Showing posts with the label google-apps-script

How to Loop through Values in Google Sheet while creating a Trigger?

How to Loop through Values in Google Sheet while creating a Trigger? I have Google Apps Script Code in the following format: var key = "ID of the Sheet"; var key1 = "ID of the Sheet"; function createTriggers() { ScriptApp.newTrigger('filter') .forSpreadsheet(key) .onEdit() .create(); } function createTriggers() { ScriptApp.newTrigger('filter') .forSpreadsheet(key1) .onEdit() .create(); } How to loop through all keys (key, key1, key2...) and create triggers via a single function? Pretty broad question. Can you be more specific? What are you trying to accomplish? – Cooper 3 mins ago I want to create a trigger for multiple sheets in a standalone script, as of now, I have to create a separate function for each trigger as seen in the above exa...

How to get the client's time in a gmail add-on?

How to get the client's time in a gmail add-on? I would like to know the timezone of the user who runs the gmail add-on. Trying the following code did not comply to the client's time zone : var formattedDate = Utilities.formatDate(new Date(), "GMT", "yyyy-MM-dd'T'HH:mm:ss'Z'"); Logger.log(formattedDate); I basically want to filter my response and just show the upcoming events to the user. An Apps Script project has it's own time zone. When you deploy an Apps Script project, it does not take on the time zone of the user. Whatever you set the time zone to in the project, that will be the time zone in the project. By default, an Apps Script project is set to your time zone. And it stays that way even if you deploy the script in an add-on. You can't get the users time zone from the script (server side) code. If you had access to their calendar, or spreadsheet, then you could get the time zone of either of...