0:00 So, as we're making spreadsheets that we're selling, I think automation is one of those things that you can add to sheets pretty easily, um, from these videos, just add a little bit of automation.
0:10 But I want to go through, uh, overall, what are the types of automations that you can do. So, so far in this course you've seen, we've done if is blank, if and if is blank, both, to add a little bit of automation without Apps Script.
0:25 And then we also added this custom function, which is not automation in and of itself, but it adds some Apps Script and it makes it.
0:33 sort of more feel like a tool than just a data set. I want to go through two more types of automations that you can do.
0:41 If you're writing some kind of script here that does something, maybe it cleans up some formatting, maybe it does like clean.
0:48 format, and in here we just clean some format. We don't return anything, but we just like clean up the sheet in some way, and we want to automate that.
0:57 Well, what is the automation we have available, and I just want to go through what is the automation we have available.
1:02 And that is over here, over in the tree. Triggers, uh, here in Apps Script. So again, just if you have not yet, go up to extensions Apps Script, and it'll open up this page, uh, and you can go over to the left side and click on triggers.
1:16 And over here, in the trigger, we can click down below here, called app add trigger, and there are two types of triggers we can trigger.
1:23 We can choose any function we want to run, and when do we want to run it, and I say there are two types here.
1:29 There are three event sources, but here's two types that I think are the most useful. It's one from some event.
1:36 I'm going to is email someone back some information we're going to do that in the next video umm doing the email and I'm going to show you how to do that but I want to show you these four options in the spreadsheet and I call these events so select some event type umm there's also time driven that's
2:24 the second type of automation now this is great if you are resetting a sheet or creating a new temp creating a new sheet from a template every day every week if you create a new checklist every day or create a new kind of stat sheet every week or create a monthly budgeting or anything like that we can
2:40 do it based on time driven functions we can go over here and say on the month on the first of the month uh do something and here i'm actually gonna show you a little bit have a few minutes here we'll create a little thing let's say we have a template complete.
2:57 we're gonna call it template and we're gonna say every month we want to we want a new copy right so if this is copied this template umm it'll be a success right and this could be a checklist this could be a template or some sort adding this kind of automation was great for budget templates anything like
3:23 that super easy to add so let's go we're gonna go to the very top we're just gonna go for a function copy template we're going to say variable SS equals spreadsheet app dot get active spreadsheet uhh variable sheet actually we'll call this template Let's do equals SS dot get sheet by name we're going
3:51 to get the sheet template all caps same name as we put here so even if you don't call it template whatever you name it um we're right here uh we're going to Thank you. To take template copy to now this copy to needs a spreadsheet we're going to just open get the idea here destination we're going to add
4:14 variable destination nation equals and the ID goes here well what is the ID we're just going to get the ID of the spreadsheet here s s dot get ID and now if I just run this if I select it here copy be happy.
4:33 Let's save this again make sure to save if this orange button is available here uh copy template run it let's see if we have any permissions we have to set or any errors nope we have no errors so we have a copy of template right there okay we can also do something like set it as active if we want but
4:55 yeah we have a copy of a template we can also name it if we would like um I think we can say set name um months Thanks.
5:04 template let's do that we can always maybe make this uhh variable the actual month but whatever we'll run it see if we get any errors we have no errors and we have created month template it's the name month template new month template new template whatever new month whatever we want to call it can set
5:24 that name okay now we go to the trigger and we want to set this at the first of the month so I showed you before add trigger we're going to choose copy template as the function to run from you uh not from spreadsheet but time driven choose here month timer on the first of the month or what we could do
5:44 maybe we need to prepare for the first of the month we do it on the 31st or the 30th or the 28th of the month we'll prepare the new month ahead of order or a week but how far whatever it is on the on the first of the month at let's say 2 a.m.
5:57 we'll save this what's going to happen is in that hour in that span it will the very first time it runs it'll choose a random time this is just how Google works and Google sheets and that's it.
6:08 which could work but the first time it runs it'll be uh a random hour and then based on whatever interval you have in this case it's every month now the next time it runs it'll run at the same time uh but it'll be between that hour and so now we have this trigger and it'll run uh we saw when we ran it
6:24 inside of our out script didn't have any hours so it shouldn't have any hours when it runs itself but I'm gonna go over here and delete this trigger here uh just to show you that you can delete triggers the thing about triggers though are uh if you create a trigger in a sheet and you have someone else
6:41 using that sheet they cannot see your triggers and you cannot see their triggers um or you might be able to see them you can't edit them at least uh the very least you cannot edit them I think now actually there was a recent update you can see that there is a trigger created by someone else the cool
6:56 thing though is even if you are running the app script you're creating the sheets for someone and they are using it your triggers will still work for them so something like that when we're creating a sheet even though I see that trigger and I can edit that trigger even though they cannot edit that trigger
7:11 it'll still work for them because it'll happen in this sheet it's it's creating the new month's template so I hope this was really helpful to understand what kind of automations are available you have at least the in in sheet automations where you have some if is blank some cool magic you have custom
7:27 functions you can add to your sheets to have some custom functionality and app script but in app script itself you have these triggers which are two time based and event based triggers in the next video we're gonna just write a really simple app app script that sends an email and you're gonna see how
7:44 I automate that enjoy!