Members-only tutorial

Watch the video and get the practice sheet with membership.

See membership options

Now Do It Every Damn Day - Learn to Code in Google Sheets Part 5

About this Tutorial

Now that we have a script that we wanna run every day, how do we run this? This is a key part of programming. It's like Cron Jobs in Apps Script

Video Transcript

<div>0:00 Now that we have a script that we wanna run every day, how do we run this? This is a key part of programming.<br>0:08 In other parts of programming is called chron jobs. Chron like a time I think a Greek word for time. So we, in Google Script and Google Sheets, we use triggers and these can trigger Learn how to automate your scripts with triggers in Google Sheets. Opens in new tab or start a script sort Discover sorting techniques to organize your data effectively. Opens in new tab of at any particular time of day or time of week.<br>0:29 We have lots of options, but I'm gonna show you one, one specific type of trigger Learn how to automate your scripts with triggers in Google Sheets. Opens in new tab .

So first off, let's go back to our app script Explore Google Apps Script to enhance your Sheets functionality. Opens in new tab , open it up and the function Understand how functions work in Google Sheets for better calculations. Opens in new tab .<br>0:41 We wanna run this copy sales data Get insights on managing and manipulating data in your spreadsheets. Opens in new tab to sales log is what we wanna trigger Learn how to automate your scripts with triggers in Google Sheets. Opens in new tab . Over on our left side of our ops script, we have five sections.<br>0:50 We've been using the editor Familiarize yourself with the Google Sheets editor for efficient coding. Opens in new tab section so far. There's also an overview. I use that very rarely. And underneath the editor Familiarize yourself with the Google Sheets editor for efficient coding. Opens in new tab is triggers.<br>0:58 So let's look at that triggers over here. On the bottom right is ad trigger Learn how to automate your scripts with triggers in Google Sheets. Opens in new tab .

We click that we choose which function Understand how functions work in Google Sheets for better calculations. Opens in new tab to run.<br>1:06 If it's not already chosen for us, we already see it's copy sales, data Get insights on managing and manipulating data in your spreadsheets. Opens in new tab log, choose which deployment. Always gonna be head from spreadsheet Master the basics of spreadsheets to improve your data management. Opens in new tab is not the event source.<br>1:16 We have to select Learn about the SELECT clause in queries for data retrieval. Opens in new tab this event source. Time driven here, we have lots of options but what we wanna do is Daytimer cuz we wanna run it between at some point in the day, every single day.<br>1:30 And what Daytimer allows you to do is select Learn about the SELECT clause in queries for data retrieval. Opens in new tab an hour out of the day.

So I usually choose something like three to 4:00 AM and we hit save.<br>1:41 Now what's it's gonna do is it will start at some point between that hour and then every time after that it'll wait 24 hours and run again.<br>1:54 So this is gonna run every 24 hours. Once it starts running, you can only pick a spec, a specific sort Discover sorting techniques to organize your data effectively. Opens in new tab of hour.<br>2:01 You can't pick at 5 0 2. At 5 0 3 you can say between 5:00 AM and 6:00 AM. But once it starts, it will then take 24 hours to start again.<br>2:15 The lovely thing about triggers is that they run on Google servers.

You do not have to spin up a server, don't have to know html, you don't have to know css, you don't have to run a server.<br>2:26 We can run this code from Google servers as much as we want. We can also have more than one trigger Learn how to automate your scripts with triggers in Google Sheets. Opens in new tab .<br>2:33 So we can run it maybe twice a day, three times a day, four times a day or four times a week or at specific times.<br>2:40 You can see all of the triggers that are available, at least the time driven ones. Here you have specific ti date and time, which is one specific time and date.<br>2:50 You have minutes, hours, days, weeks and months.

One interesting thing about this is that If you go and copy this sheet in particular, so out of all these videos, if you've been copying the sheets as we go along and seeing all the steps, you'll be able to open app script Explore Google Apps Script to enhance your Sheets functionality. Opens in new tab and see the script.<br>3:11 But you will not be able to see my trigger Learn how to automate your scripts with triggers in Google Sheets. Opens in new tab .

And this is even true on sheets that you share Find out how to share your Google Sheets with others effectively. Opens in new tab with other people.<br>3:18 So if you and your boss or you and your coworker or you and your employees are sharing Find out how to share your Google Sheets with others effectively. Opens in new tab a sheet, one of you creates a trigger Learn how to automate your scripts with triggers in Google Sheets. Opens in new tab , the other people cannot see that trigger Learn how to automate your scripts with triggers in Google Sheets. Opens in new tab , but they can be affected by it.<br>3:30 So if somebody writes a script and I create a trigger Learn how to automate your scripts with triggers in Google Sheets. Opens in new tab , this trigger Learn how to automate your scripts with triggers in Google Sheets. Opens in new tab will trigger Learn how to automate your scripts with triggers in Google Sheets. Opens in new tab that script to run even if someone else created the script, but they won't be able to see my trigger Learn how to automate your scripts with triggers in Google Sheets. Opens in new tab .<br>3:44 So that is one downfall of Google Script triggers here.

Another restriction of app script Explore Google Apps Script to enhance your Sheets functionality. Opens in new tab that might be interesting based on triggers is that an app script Explore Google Apps Script to enhance your Sheets functionality. Opens in new tab can only run for 30 seconds.<br>4:01 It will time out after that.

So you can't really time things like Pomodoro like 25 minutes, you can't time hours.<br>4:09 There's some limitations to app script Explore Google Apps Script to enhance your Sheets functionality. Opens in new tab and there are actually a lot more, but you don't really run into them very often.<br>4:17 One more limitation before we end this video is that triggers, if I create a script that triggers an edit, oned scripts won't be triggered, meaning a person has to edit the sheet.<br>4:34 So a triggered script will not trigger Learn how to automate your scripts with triggers in Google Sheets. Opens in new tab an oned script to run. I hope that makes sense.

Essentially an oned must only be user is editing a sheet so it won't be triggered by triggers.<br>4:52 In the next video I'll actually go into more different types of triggers, but I just wanted to get this one to you and make sure you understood triggers cuz it's probably one of the most important parts of automating things and creating the scripts is that you can run them automatically.<br>5:08 This is truly automatic. Once you start it, it will run forever until you delete that trigger Learn how to automate your scripts with triggers in Google Sheets. Opens in new tab . Let me show you how to delete that trigger Learn how to automate your scripts with triggers in Google Sheets. Opens in new tab .<br>5:16 We go to edit, actually we don't even go to edit.

We go to the three buttons here, delete trigger Learn how to automate your scripts with triggers in Google Sheets. Opens in new tab . That's how we can delete forever this trigger Learn how to automate your scripts with triggers in Google Sheets. Opens in new tab .<br>5:25 So again, I can even save this trigger Learn how to automate your scripts with triggers in Google Sheets. Opens in new tab and you're gonna copy this page and won't be able to see the trigger Learn how to automate your scripts with triggers in Google Sheets. Opens in new tab so that I create.<br>5:30 So I just deleted it. Thanks for watching. See the next video where Understand the WHERE clause in queries for filtering data. Opens in new tab we go into a lot more concepts and I share Find out how to share your Google Sheets with others effectively. Opens in new tab with you more opportunities of what can happen in app Script Explore Google Apps Script to enhance your Sheets functionality. Opens in new tab .<br>5:40 I hope you've been enjoying learning to code in app.</div>