Time Based Trigger - Apps Script | Script Service ~ Episode 3.1

Поділитися
Вставка
  • Опубліковано 11 гру 2024

КОМЕНТАРІ • 35

  • @davemacdonald7910
    @davemacdonald7910 3 роки тому +1

    Learning for the first time and these videos are extremely helpful! Thanks so much for this!

  • @nsikakumoh1883
    @nsikakumoh1883 3 роки тому

    Thank you so so much David. As an Apps Script enthusiast, I really love this video.

  • @edgarzh
    @edgarzh 2 роки тому

    Really thank you to make and share these videos. It's extremely helps!

  • @noob9inz457
    @noob9inz457 3 роки тому

    You are a gem brother. Take love.

  • @henryramos8392
    @henryramos8392 Рік тому

    Thanks for the informacion, friend

  • @kingjoshuamanatad1402
    @kingjoshuamanatad1402 3 роки тому

    Awesome content!

  • @ZabuArts
    @ZabuArts 2 роки тому

    Thank you very much!

  • @gsheetssolutions
    @gsheetssolutions 2 роки тому

    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?

  • @TheEnlightened
    @TheEnlightened 3 роки тому +1

    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.

    • @DavidWeissProgramming
      @DavidWeissProgramming  3 роки тому

      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!

    • @TheEnlightened
      @TheEnlightened 3 роки тому

      @@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

  • @satyajit2019
    @satyajit2019 Рік тому

    I want to send reminder each and every day Monday to Friday
    On a specific time
    Can you please create the video for me.

  • @EthanPatrick-k4w
    @EthanPatrick-k4w 4 місяці тому

    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 +/-

    • @EthanPatrick-k4w
      @EthanPatrick-k4w 4 місяці тому

      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();
      }

  • @angelsano4513
    @angelsano4513 2 роки тому

    How do I automate the running of the trigger?

  • @adityanalwaya6065
    @adityanalwaya6065 2 роки тому

    Hi I want to send automatically google form to myself every day at specific time on my Email address can I do it???

  • @UtkarshAgarwal
    @UtkarshAgarwal 3 роки тому

    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?

  • @raktimasensarma82
    @raktimasensarma82 4 роки тому

    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!

  • @feroscyp8250
    @feroscyp8250 3 роки тому

    could i run a function every secon?

  • @ruairidhgrass3479
    @ruairidhgrass3479 3 роки тому

    I get TypeError: ScriptApp.newTrigger(...).timeBased.after is not a function any idea whats going on?

    • @DavidWeissProgramming
      @DavidWeissProgramming  3 роки тому

      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! :)

  • @FRAN-vd9rl
    @FRAN-vd9rl 3 роки тому

    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.

  • @MsElegant01
    @MsElegant01 3 роки тому

    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.

    • @DavidWeissProgramming
      @DavidWeissProgramming  3 роки тому +1

      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! :)

    • @MsElegant01
      @MsElegant01 3 роки тому

      @@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. :-(

  • @peterfrost250
    @peterfrost250 3 роки тому

    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?

  • @ms.breese8157
    @ms.breese8157 4 роки тому

    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!

    • @DavidWeissProgramming
      @DavidWeissProgramming  4 роки тому

      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();
      }

  • @jerickalegarbes6906
    @jerickalegarbes6906 3 роки тому

    do time-based triggers only run while the spreadsheet is open? I'm new to this.

    • @DavidWeissProgramming
      @DavidWeissProgramming  3 роки тому +2

      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.

  • @Fernitano
    @Fernitano 3 роки тому

    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!

    • @DavidWeissProgramming
      @DavidWeissProgramming  3 роки тому +1

      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 :)

  • @kbtmukhil9254
    @kbtmukhil9254 3 роки тому

    how can send paragraphs by mail

    • @DavidWeissProgramming
      @DavidWeissProgramming  3 роки тому

      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) " });