Hey David, how do I stopped if have a script triggers daily creating a copy of template and I want it it stopped at the end of the month. How do i do this with codes?
Hi, what if my function recieves a e.response.getRespondentEmail(), which I want to save and use for all of my triggers, how do I save the email I got from the google forms trigger and use it for all future triggers I create which are basically tons of autoresponders of emails for the same respondent? The newTrigger() function recieves no variables I think... which is why its not working for me. I would apperciate your advice on this matter, thanks.
Hm, interesting! If I understand correctly, you are trying to save a Form respondent's email address and create a trigger such that the function (such as sending an email) only fires for that email address. Okay, yes, you are correct. The newTrigger() function receives no variables, so you'll have to store this respondent's email another way. If I were addressing the problem, I would either save the respondent's email in either Properties Service by using the method PropertiesService.getScriptProperties().setProperty(emailAdress, message) (See Season 12 ua-cam.com/video/yRyMM2v0A5c/v-deo.html for more info on how), or in a Spreadsheet somewhere. Then I would set up one trigger that called one function which would loop through all the email addresses in the Spreadsheet and send a personalized message for each one. The personalized messages as well as any other data you wanted to store could be included alongside the email address in the Spreadsheet too! Hopefully this explanation helped? Let me know if you're still unclear on anything!
@@DavidWeissProgramming Thanks for helping. I did exactly that but the problem is that it saves only one mail in the PropertiesService var, which means that if two people opt in at the same time, it creates problems as the trigger hasnt been called/finished properly and so all emails wouldnt be sent to the initial respondent but only to the ultimate one. Thoughts on how to deal with this situation? It is very urgent as I have tried solving this for the longest time. Thanks
Theoretically, could I set up a daily time based trigger in the Triggers UI to run between 12AM-1AM for the setUpTrigger function and use the at() method to specify a specific time by modifying new Date() when I run it at midnight? Get new Date, then modify so it happens on a specific time of that date. This would allow me to do basically the same thing as atHour().nearMinute() without the 15 minute +/-
something like this: function createTrigger() { var now = new Date(); // Convert the current time to Pacific Time var convertPacific = now.toLocaleString('en-US', { timeZone: 'America/Los_Angeles' }); // Create a new Date object with the Pacific Time var pacificNow = new Date(convertPacific); // Set the time to 4:00 PM var runtime = new Date(pacificNow.setHours(16, 0, 0, 0)); // 16:00:00.000 is 4:00 PM Logger.log(now); Logger.log(runtime); // Create the trigger to run at 4 PM Pacific Time ScriptApp.newTrigger('closeSnoozed') .timeBased() .at(runtime) .create(); }
Thank you so much, you explained in a very easy way. I am a beginner in coding but the way you explained really helped me to clear all my doubts and i was able to connect with your process at one go. Amazing video. I have a question too, if i have 2 functions written on a single script, then how can i merge those two and run this time trigger for both of them at the same time?
I made a script to entry some data in a google form, and set to trigger it continuously every after 5 mins. Actually it is my school attendance form. So it is closed all the day but in a certain time it opens and I want after a successful submit these script will stop for a few hours and will start again according to my trigger. If you could help me with these I would be really grateful to you. Thanks!
Hi Ruairidh! It looks like the TypeError you're getting is because you're not actually calling the "timeBased" method. To call it, you have to add parentheses after the method name. Like this: .timeBased() Putting it all together, your code should look similar to this: ScriptApp.newTrigger('sendEmail').timeBased().after(10000).create(); Does that make sense? Feel free to reply if you need more help! :)
hi David, your channel is pure wisdom! one question i was wondering, i think i've been using time based triggers but just by clicking the clock button, there is also the clock button in the new IDE of the google editor. Is that the same? i haven't found in the clock options the option to run a script after X miliseconds of a previously run script.
Is it possible to create time based alert inside time based alert. Eg. 1st alert at specific time every day triggering every 5m trigger? Here 5m trigger will run main function.
Hi Vidya! Absolutely! You can create and run triggers that set up other triggers to run. I did a demonstration similar to this in my "Exact Time Trigger" Episode: ua-cam.com/video/Vob6Qy01-_Y/v-deo.html Check it out! :)
@@DavidWeissProgramming Hi thanks alot for reply. I tried this code but second trigger is getting disabled even before executing main function. I have similar code with little bit different logic but in that code too second trigger is getting disabled before execution. Can u pls guide me where am I going wrong? Or Google changed its trigger system? I am struggling with the code since a week. :-(
I have a page with 2-3 triggers updating 10-20 items by MINUTE. But...I seem to be limited by Google. Is there a limit to riggers/refreshed to a google sheet? 90 minutes a day?
Hello, Could you walk me through how I could set up a Timebase Trigger for clearing parts of my table? I am trying to set up an attendance sheet and I would like the column in my table to be cleared at midnight every day. I have multiple sheets that I need this for. Thank you!
Hello Ms. Breese! That should be easy. You'll need to set up two functions for this. The first will set up your time based trigger to run once a day at midnight. The second will be the function it calls which actually clears the column from the Sheet. In this second function you'll need the url of the Sheet (or if you have multiple Sheets, you'll need all of the urls). Then connect to the Sheet in Apps Script via SpreadsheetApp. Get the worksheet name and range and then use the method clear(). Additionally, you'll need to manually run the function clearAttendanceSheet() just once before setting up the trigger in order to authorize SpreadsheetApp to operate on your behalf. Below is an example of how it would work for just one Sheet. If you have multiple Sheets, just repeat the same logic for all of them. function createNewTrigger() { ScriptApp.newTrigger('clearAttendanceSheet') .timeBased() .everyDays(1) .atHour(0) .create(); } function clearAttendanceSheet() { const spreadsheet = SpreadsheetApp.openByUrl('docs.google.com/spreadsheets/d/1Q85vRQFzTfzaW-jSTNMx7D0Mny-loPXUxnWcXBNlIlw/edit#gid=0'); const sheet = spreadsheet.getSheetByName('Sheet1'); sheet.getRange('A:A').clear(); }
Hi Jerick. Nope! Time-based triggers run regardless of whether spreadsheet is open or not. That means it will run even if you close the browser, power off your laptop and store it away.
Ey! Great video! I tried but appears TypeError: Cannot read property 'getRange' of null at myFunction(Código:2:29) Could you help me? I´m would like to bring btc value, with importdata from Binance API. Thanks!
From the error alone, it seems that Apps Script cannot find the Sheet you are looking for, and thus returning null. "Null" has no method called getRange() and thus it is erroring out. That sounds like a fun project! I've done similar things myself. Be sure to check out my Patreon page: www.patreon.com/DavidWeissProgramming and consider becoming a platinum patron if you want help building it out :)
Hi KBT MUKHIL! You can send paragraphs with the same exact method used in the video above! Use the method GmailApp.sendEmail(recipient, subject, body); or MailApp.sendEmail(recipient, subject, body); and replace the "body" argument with your paragraph. If you want your paragraph to be slightly more stylized and formatted, include your paragraph as HTML in the optional arguments. For example, use this: GmailApp.sendEmail(recipient, subject, body, { "html": " (add your html here) " });
Learning for the first time and these videos are extremely helpful! Thanks so much for this!
You're very welcome! Glad you like them!
Thank you so so much David. As an Apps Script enthusiast, I really love this video.
Really thank you to make and share these videos. It's extremely helps!
You are a gem brother. Take love.
Thanks for the informacion, friend
Awesome content!
Thank you very much!
Hey David, how do I stopped if have a script triggers daily creating a copy of template and I want it it stopped at the end of the month. How do i do this with codes?
Hi, what if my function recieves a e.response.getRespondentEmail(), which I want to save and use for all of my triggers, how do I save the email I got from the google forms trigger and use it for all future triggers I create which are basically tons of autoresponders of emails for the same respondent? The newTrigger() function recieves no variables I think... which is why its not working for me.
I would apperciate your advice on this matter, thanks.
Hm, interesting! If I understand correctly, you are trying to save a Form respondent's email address and create a trigger such that the function (such as sending an email) only fires for that email address. Okay, yes, you are correct. The newTrigger() function receives no variables, so you'll have to store this respondent's email another way. If I were addressing the problem, I would either save the respondent's email in either Properties Service by using the method PropertiesService.getScriptProperties().setProperty(emailAdress, message) (See Season 12 ua-cam.com/video/yRyMM2v0A5c/v-deo.html for more info on how), or in a Spreadsheet somewhere. Then I would set up one trigger that called one function which would loop through all the email addresses in the Spreadsheet and send a personalized message for each one. The personalized messages as well as any other data you wanted to store could be included alongside the email address in the Spreadsheet too! Hopefully this explanation helped? Let me know if you're still unclear on anything!
@@DavidWeissProgramming Thanks for helping. I did exactly that but the problem is that it saves only one mail in the PropertiesService var, which means that if two people opt in at the same time, it creates problems as the trigger hasnt been called/finished properly and so all emails wouldnt be sent to the initial respondent but only to the ultimate one.
Thoughts on how to deal with this situation? It is very urgent as I have tried solving this for the longest time.
Thanks
I want to send reminder each and every day Monday to Friday
On a specific time
Can you please create the video for me.
Theoretically, could I set up a daily time based trigger in the Triggers UI to run between 12AM-1AM for the setUpTrigger function and use the at() method to specify a specific time by modifying new Date() when I run it at midnight? Get new Date, then modify so it happens on a specific time of that date. This would allow me to do basically the same thing as atHour().nearMinute() without the 15 minute +/-
something like this:
function createTrigger() {
var now = new Date();
// Convert the current time to Pacific Time
var convertPacific = now.toLocaleString('en-US', { timeZone: 'America/Los_Angeles' });
// Create a new Date object with the Pacific Time
var pacificNow = new Date(convertPacific);
// Set the time to 4:00 PM
var runtime = new Date(pacificNow.setHours(16, 0, 0, 0)); // 16:00:00.000 is 4:00 PM
Logger.log(now);
Logger.log(runtime);
// Create the trigger to run at 4 PM Pacific Time
ScriptApp.newTrigger('closeSnoozed')
.timeBased()
.at(runtime)
.create();
}
How do I automate the running of the trigger?
Hi I want to send automatically google form to myself every day at specific time on my Email address can I do it???
Thank you so much, you explained in a very easy way. I am a beginner in coding but the way you explained really helped me to clear all my doubts and i was able to connect with your process at one go. Amazing video. I have a question too, if i have 2 functions written on a single script, then how can i merge those two and run this time trigger for both of them at the same time?
I made a script to entry some data in a google form, and set to trigger it continuously every after 5 mins. Actually it is my school attendance form. So it is closed all the day but in a certain time it opens and I want after a successful submit these script will stop for a few hours and will start again according to my trigger. If you could help me with these I would be really grateful to you. Thanks!
could i run a function every secon?
I get TypeError: ScriptApp.newTrigger(...).timeBased.after is not a function any idea whats going on?
Hi Ruairidh! It looks like the TypeError you're getting is because you're not actually calling the "timeBased" method. To call it, you have to add parentheses after the method name. Like this:
.timeBased()
Putting it all together, your code should look similar to this:
ScriptApp.newTrigger('sendEmail').timeBased().after(10000).create();
Does that make sense? Feel free to reply if you need more help! :)
hi David, your channel is pure wisdom! one question i was wondering, i think i've been using time based triggers but just by clicking the clock button, there is also the clock button in the new IDE of the google editor. Is that the same? i haven't found in the clock options the option to run a script after X miliseconds of a previously run script.
Is it possible to create time based alert inside time based alert. Eg. 1st alert at specific time every day triggering every 5m trigger? Here 5m trigger will run main function.
Hi Vidya! Absolutely! You can create and run triggers that set up other triggers to run. I did a demonstration similar to this in my "Exact Time Trigger" Episode: ua-cam.com/video/Vob6Qy01-_Y/v-deo.html
Check it out! :)
@@DavidWeissProgramming Hi thanks alot for reply. I tried this code but second trigger is getting disabled even before executing main function. I have similar code with little bit different logic but in that code too second trigger is getting disabled before execution. Can u pls guide me where am I going wrong? Or Google changed its trigger system? I am struggling with the code since a week. :-(
I have a page with 2-3 triggers updating 10-20 items by MINUTE. But...I seem to be limited by Google. Is there a limit to riggers/refreshed to a google sheet? 90 minutes a day?
Hello,
Could you walk me through how I could set up a Timebase Trigger for clearing parts of my table? I am trying to set up an attendance sheet and I would like the column in my table to be cleared at midnight every day. I have multiple sheets that I need this for. Thank you!
Hello Ms. Breese! That should be easy. You'll need to set up two functions for this. The first will set up your time based trigger to run once a day at midnight. The second will be the function it calls which actually clears the column from the Sheet. In this second function you'll need the url of the Sheet (or if you have multiple Sheets, you'll need all of the urls). Then connect to the Sheet in Apps Script via SpreadsheetApp. Get the worksheet name and range and then use the method clear(). Additionally, you'll need to manually run the function clearAttendanceSheet() just once before setting up the trigger in order to authorize SpreadsheetApp to operate on your behalf. Below is an example of how it would work for just one Sheet. If you have multiple Sheets, just repeat the same logic for all of them.
function createNewTrigger() {
ScriptApp.newTrigger('clearAttendanceSheet')
.timeBased()
.everyDays(1)
.atHour(0)
.create();
}
function clearAttendanceSheet() {
const spreadsheet = SpreadsheetApp.openByUrl('docs.google.com/spreadsheets/d/1Q85vRQFzTfzaW-jSTNMx7D0Mny-loPXUxnWcXBNlIlw/edit#gid=0');
const sheet = spreadsheet.getSheetByName('Sheet1');
sheet.getRange('A:A').clear();
}
do time-based triggers only run while the spreadsheet is open? I'm new to this.
Hi Jerick. Nope! Time-based triggers run regardless of whether spreadsheet is open or not. That means it will run even if you close the browser, power off your laptop and store it away.
Ey! Great video! I tried but appears TypeError: Cannot read property 'getRange' of null
at myFunction(Código:2:29)
Could you help me? I´m would like to bring btc value, with importdata from Binance API.
Thanks!
From the error alone, it seems that Apps Script cannot find the Sheet you are looking for, and thus returning null. "Null" has no method called getRange() and thus it is erroring out.
That sounds like a fun project! I've done similar things myself. Be sure to check out my Patreon page: www.patreon.com/DavidWeissProgramming and consider becoming a platinum patron if you want help building it out :)
how can send paragraphs by mail
Hi KBT MUKHIL! You can send paragraphs with the same exact method used in the video above! Use the method GmailApp.sendEmail(recipient, subject, body); or MailApp.sendEmail(recipient, subject, body); and replace the "body" argument with your paragraph. If you want your paragraph to be slightly more stylized and formatted, include your paragraph as HTML in the optional arguments. For example, use this: GmailApp.sendEmail(recipient, subject, body, { "html": " (add your html here) " });