Members-only tutorial
Watch the video and get the practice sheet with membership.
About this Tutorial
Sheet Resources
Apps Script APIs used
Video Transcript
<div>00:00 So what I want to do today is create an automated project management sheet. This is something that I personally made myself recently, so it's pretty much on the top of my mind.<br>00:10 To manage projects internally, if you have multiple people, you have like a project, you have a status, and you have some person.<br>00:20 name assigned, or assignee, or someone who's assigned to this project and they have some status. So we have, let's say, project 1, project 2, and project 3.<br>00:32 And we want to do a few things.
One, we want to create a dropdown Learn how to ensure data integrity with validation in your Google Sheets. Opens in new tab menu that has some statuses here.<br>00:38 We'll click drop-down we'll add here. Uh, completed, or complete, uh needs review, and we'll say in progress. So we have three, we can say yellow for this one, needs review has a red, and complete is green.<br>00:55 Uh, once something's in progress, it'll change to yellow, and then when we need a review, Thank you.
Ah, it will change to red, and complete will be green.<br>01:03 But, if we have a number Understand how to work with numbers effectively in Google Sheets. Opens in new tab of projects here, let's change this to colon b, if we have a number Understand how to work with numbers effectively in Google Sheets. Opens in new tab of projects here, it's gonna get pretty messy here.<br>01:12 So, we're gonna call this in progress, ah, and we want to, or actually we'll call it projects, and we want to create a duplicate Find out how to manage and remove duplicate entries in your sheets. Opens in new tab , of this, and call it complete.<br>01:23 But, we want to delete all of these items.
So, let's make a little header Discover the importance of headers in organizing your data. Opens in new tab here, um, I do want to just use, let's make this a little bit prettier with quicksand, twelve, we have project status name, we want some names here of people who in our company maybe we assign each person, we have Carl, let's say<br>01:45 , and Ben, just two, we can give them colors as well, Carl is purple, and Ben is blue.
Okay, we can have that there, and what we want to do is a few things to this, to make this really awesome.<br>02:00 Automated, to make this ah a place where Explore how to filter data using the query where clause. Opens in new tab we can keep track of what projects are completed, what's in progress, who is it assigned to, and if they're completed or not.<br>02:14 But what we want to do is add automated emails. So we're going to go to Apps Script Get started with Google Apps Script to automate your tasks. Opens in new tab . We're going to automate these emails when statuses are changed.<br>02:24 We're also going to move anything that's complete over to the Complete tab.
So one thing about the Complete tab I want to do is delete everything except the first two rows.<br>02:35 That's just something I do to make it cleaner. I want to also make it cleaner. have exactly the same formatting Learn tips for formatting your sheets to enhance readability. Opens in new tab as the other sheet.<br>02:47 You'll see why soon because basically what we're going to do is we're going to insert a line above here each time it's complete.<br>02:56 And we want the same formatting Learn tips for formatting your sheets to enhance readability. Opens in new tab each time. So.
Let's go back to our Apps Script Get started with Google Apps Script to automate your tasks. Opens in new tab and start writing our Apps Script Get started with Google Apps Script to automate your tasks. Opens in new tab .<br>03:05 To do automations when we edit things we'll use onEdit and we'll use an event here as the input. We're going to do this to move.<br>03:15 So this onEdit will move when complete. We're going to need to do another function Understand how to create and use functions in Google Sheets. Opens in new tab here. Create a function Understand how to create and use functions in Google Sheets. Opens in new tab to send email when needs review.<br>03:32 We also want to create a function Understand how to create and use functions in Google Sheets. Opens in new tab to send email when assigned.
So if we have individuals here here, and say I'm a project manager, and I say I have, I create a project, I say it's in progress, or nothing, and I just assign someone, say Carl, I want to automatically let Carl know, hey you've been assigned<br>03:53 this project, go here and check it. Uh, go here meaning this sheet. Okay.
So let's, let's, do that there, and we're going to have to do these separately because there's a little bit of an issue with onEdit as a simple function Understand how to create and use functions in Google Sheets. Opens in new tab , or a simple trigger Find out how to use simple triggers for basic automation. Opens in new tab rather, it cannot send email, but we do have a way to<br>04:13 onEdit send emails, which I will show you later, uh, but the first thing we want to do is move anything that's completely needed to the complete tab.<br>04:22 So how do we do that?
First, we need to make sure we get the row, we need some variables basically, because we're going to say if row is greater than one, meaning it's not the header Discover the importance of headers in organizing your data. Opens in new tab , and column, or c-o-l, we're going to use as a, actually we'll use column here. Column is greater is equal to two, making<br>04:43 sure that we're editing the second column, double ampersand again, and edit value, the value that we're editing, is equal to complete.<br>04:55 Did we say complete or completed? Complete. There we go.
And we want to make sure we're on the right project, uh on the right tab, which is projects.<br>05:07 So tab name equals projects. So we want to make sure all of those are true, and then we will, uh we'll come here and move the row.<br>05:18 Which in, uh. that we will copy the row to complete, and we will come back and delete the row.
So that's what moving really is, there's not a single function Understand how to create and use functions in Google Sheets. Opens in new tab that says hey move this row.<br>05:37 What we do is create a function Understand how to create and use functions in Google Sheets. Opens in new tab that copies the row to complete, we have to actually create actually also insert a row at the top of complete, uh copy it and then come back and delete the row from projects.<br>05:53 That's how we quote unquote move something. So what we got to get these variables variable row equals.
Event dot range Learn about selecting and manipulating ranges in your sheets. Opens in new tab dot get row pretty simple variable column is going to be equal is event dot range Learn about selecting and manipulating ranges in your sheets. Opens in new tab dot get column variable edit value meaning the value that we're editing to will be event.<br>06:20 dot value that one is pretty simple just value no just value it's it's auto completing there we go variable sheet name Understand how to reference and manage sheet names effectively. Opens in new tab is equal to spread sheet app dot get active spread sheet actually not spread sheet sorry All right.<br>06:40 sheet get name so this sheet name Understand how to reference and manage sheet names effectively. Opens in new tab actually it's gonna be tab name here tab name is going to be projects and it's this name here we can also log these if we wish um but let's cut first insert a row at the top of complete which we need variable complete equals spreadsheet Get familiar with the structure and features of Google Sheets. Opens in new tab app dot get active spreadsheet Learn how to interact with the currently active spreadsheet. Opens in new tab <br>07:08 dot get sheet by name complete so we don't have to type that over and over again we can just say complete dot insert row Discover how to insert rows dynamically in your Google Sheets. Opens in new tab after actually we want before three and nope sorry before two the issue here is if we insert a row underneath the first row it will have the formatting Learn tips for formatting your sheets to enhance readability. Opens in new tab of the first row but if we insert<br>07:36 a row above the second row it will have the formatting of the second row.
So that's really important to know we want to insert there okay we did that now copy the row from projects to complete so we have the row that we're editing we know that we're editing it to complete so all we need to do is again<br>07:59 get the variable projects so this will be the same except a different name which will be actually misspelled complete there.<br>08:10 Projects. Now we need to copy the row to complete so we'll do projects dot umm. No we don't need to do that.<br>08:22 Actually we need to variable range Learn about selecting and manipulating ranges in your sheets. Opens in new tab to copy. We can just do it this way. uh complete dot get range Learn about selecting and manipulating ranges in your sheets. Opens in new tab .
We're gonna go to the row.<br>08:37 We want one column and we want only one row sorry the first column one row and then the number Understand how to work with numbers effectively in Google Sheets. Opens in new tab of columns is gonna be max columns.<br>08:47 We're gonna need that variable as well variable max columns equals and this will be pretty simple complete dot. Sorry not complete projects.<br>08:59 Projects dot get. Max columns. We also need max columns complete. So we'll call this projects equals complete dot get. it.<br>09:20 Max columns. We'll need that as well. Okay, so we are going to actually project. Sorry. Projects dot get range Learn about selecting and manipulating ranges in your sheets. Opens in new tab .
Get the row, get all of the columns, get values Understand how to work with values and data types in Sheets. Opens in new tab .<br>09:33 No, we don't need the values Understand how to work with values and data types in Sheets. Opens in new tab . We'll just do copy too. Where Explore how to filter data using the query where clause. Opens in new tab are we copying it to? Is we're copying it to complete?<br>09:39 complete. 3 3 3 3 3 3 Umm. Get range Learn about selecting and manipulating ranges in your sheets. Opens in new tab . We are going to go to the second row because we've inserted a row.<br>09:49 So we know the second row is blank. We do 1 1 and max columns complete. This should be max column projects.<br>10:00 Here. There we go. And that should come uhh if we say project is complete. It is now entered here. But now we have to go back and delete it from projects.<br>10:17 So how do we do that?
We just go to projects. Delete. Row. And which row do we delete? We delete the row that we got up here as well.<br>10:26 So that is saved. And we're only doing that if it's complete. So we can check this by doing something like needs review.<br>10:34 And making sure that that does not copy over here. It is not doing it. But now let's do complete. And it should- Delete this row.<br>10:42 There we go. It's deleted the row. Fantastic. So we have our automation done on complete. But the next thing is we want to send an email when someone uh changes to needs review.<br>10:54 Okay.
Let's do that down here. I'm going to create a new function Understand how to create and use functions in Google Sheets. Opens in new tab called send review email. We have an event here as well.<br>11:08 What we need to do is we're going to use the on edit here as a simple trigger Find out how to use simple triggers for basic automation. Opens in new tab . But we're going to use the on edit as a installable trigger Explore how to set up installable triggers for advanced automation. Opens in new tab for this one because permission.<br>11:20 For sending email does not allow us umm to do it through a simple trigger Find out how to use simple triggers for basic automation. Opens in new tab . We need to do a installable trigger Explore how to set up installable triggers for advanced automation. Opens in new tab which I will show you again in a second.<br>11:31 But we will use exactly the same stuff here. So we're going to use all this as well.
We're having the same event umm but we want to make sure it is needs review.<br>11:48 And if that is so, we will send an email. Who are we going to send an email to? Well let's first do Gmail app.<br>11:55 Gmail app.send email. And this is going to be a simple email. It's going to have some- one who it's to, a subject and a body.<br>12:05 So we need to create those variables. Variable two equals umm I think it's session dot get active user. But we can also get owner Learn how to find and use the owner information in your spreadsheets. Opens in new tab .<br>12:16 I think it's going to be spreadsheet Get familiar with the structure and features of Google Sheets. Opens in new tab app dot get owner Learn how to find and use the owner information in your spreadsheets. Opens in new tab . Get active spreadsheet Learn how to interact with the currently active spreadsheet. Opens in new tab get owner Learn how to find and use the owner information in your spreadsheets. Opens in new tab .
This should, let's look at this uh ah we need to get owner Learn how to find and use the owner information in your spreadsheets. Opens in new tab dot get email.<br>12:32 That's what we need. So whoever is the owner Learn how to find and use the owner information in your spreadsheets. Opens in new tab of this spreadsheet Get familiar with the structure and features of Google Sheets. Opens in new tab should be the one who is umm getting these emails.<br>12:40 That's what we're doing here. So I don't have to put my own email in there. Someone can use this ah without putting their own email in.<br>12:46 So the subject variable subject should probably be needs review and we want to get the project name. Project name. How do we get the project name?<br>12:59 Well we know what row we're on.
So we just need to do variable project name equals spreadsheet Get familiar with the structure and features of Google Sheets. Opens in new tab app dot git.<br>13:07 Umm. Let's get these this as well. We want projects dot git range Learn about selecting and manipulating ranges in your sheets. Opens in new tab . The range Learn about selecting and manipulating ranges in your sheets. Opens in new tab is going to be the row.<br>13:21 One uh one column, number Understand how to work with numbers effectively in Google Sheets. Opens in new tab of rows one, number Understand how to work with numbers effectively in Google Sheets. Opens in new tab of columns one. So this is just the very first thing in A column and we're going to get value.<br>13:32 And that is going to be need review, needs review project name. Variable body is equal to. You Hey, just need this project reviewed.<br>13:45 Umm. What we want to do here is also put project name. And then, it's going to be interesting.
Plus, we're going to create a slash N is a new line.<br>14:00 line. . I'm going to do that twice. And then I'm going to put um the URL of the spreadsheet Get familiar with the structure and features of Google Sheets. Opens in new tab . So we don't have to copy paste this URL.<br>14:11 It will automatically get the URL for us. So variable sheet URL equals spreadsheet Get familiar with the structure and features of Google Sheets. Opens in new tab app get active spreadsheet Learn how to interact with the currently active spreadsheet. Opens in new tab . Get URL.
That's pretty simple.<br>14:23 And we're just going to include that in the email so that we can click on here and make sure if there's any other information here we just want that project name that needs to review.<br>14:32 Maybe we have some extra columns here of information like uh where Explore how to filter data using the query where clause. Opens in new tab the ultimate link is, whatever the project is. Is it happy?<br>14:40 I mean umm notes Discover how to add and manage notes in your Google Sheets. Opens in new tab on it, updates, last date, whatever. Wanna do that. So, we're gonna send that email. Let's test that email now.<br>14:53 Let's see we have an invel left and say 36. Oh, this is, This should be a plus sign.
There we go.<br>15:02 Nice handy error Understand common errors in Google Sheets and how to fix them. Opens in new tab message. We wanna automate project management. So the first time we run this, we will need to authorize it.<br>15:20 So, We will get an error Understand common errors in Google Sheets and how to fix them. Opens in new tab here, but we just wanna authorize all of this. Let's allow. So the error Understand common errors in Google Sheets and how to fix them. Opens in new tab will always come up that the range Learn about selecting and manipulating ranges in your sheets. Opens in new tab is undefined here.<br>15:32 If we're running this on edit from here. But we're not gonna be running the on edit from inside of our IDE or in our app script Get started with Google Apps Script to automate your tasks. Opens in new tab .<br>15:39 We're gonna be running the, running it in our projects. So let's say project test.
We need to say needs review.<br>15:49 And this should trigger Explore different types of triggers for automating tasks in Sheets. Opens in new tab the email. And so we can always see here in executions if there is some failure. Like this one was a failure, but it was the one we, ran.<br>16:01 We can look at our inbox and see if we get an email. Let's look again. Needs review. Let's make sure everything is hunky-dory.<br>16:16 Oh, the wh- One thing that I actually forgot to do was trigger Explore different types of triggers for automating tasks in Sheets. Opens in new tab this send review email. And I was gonna show you that.<br>16:25 So now I will show you that right now. So let's go over to triggers.
We need actually create the trigger Explore different types of triggers for automating tasks in Sheets. Opens in new tab .<br>16:30 In the instance of a simple trigger Find out how to use simple triggers for basic automation. Opens in new tab we do not need to create it, but now we need an installable trigger Explore how to set up installable triggers for advanced automation. Opens in new tab because we have those email permissions.<br>16:38 So we go to the bottom right add trigger Explore different types of triggers for automating tasks in Sheets. Opens in new tab . Bigger. We're going to choose our function Understand how to create and use functions in Google Sheets. Opens in new tab here. Send review email. We do want the event source to be from spreadsheet Get familiar with the structure and features of Google Sheets. Opens in new tab , but we want to change it to on edit.<br>16:49 So this sounds the same as using the simple trigger Find out how to use simple triggers for basic automation. Opens in new tab on edit, but it allows us to send emails because we cannot send an email.<br>16:58 We cannot give grant permission.
In the right permissions to the simple trigger Find out how to use simple triggers for basic automation. Opens in new tab . So now that we have that we can delete this needs review.<br>17:08 Uh let's say we've assigned it to Carl. Needs review. And now we can go back to our executions and see if there's any error Understand common errors in Google Sheets and how to fix them. Opens in new tab .<br>17:20 Or if it is triggered. So now we have a function Understand how to create and use functions in Google Sheets. Opens in new tab send review email. It has a trigger Explore different types of triggers for automating tasks in Sheets. Opens in new tab . It has been triggered.<br>17:27 We should get an email. There we go. Needs review project test. And we have a link back to the sheet.<br>17:35 Perfect. So next thing we need to do on our list.
Is we want to create a function Understand how to create and use functions in Google Sheets. Opens in new tab that sends email when assigned.<br>17:44 So this is great for someone who's working on these projects to let the person in charge know hey we need this reviewed.<br>17:53 We already added the complete. So someone can come in here complete and this will move over here to the completed tab.<br>17:59 through the system for Automate this But if I want to assign a project. Carl's project. I'm it's not in progress yet.<br>18:09 It doesn't need a review yet. It needs to get started.
And so I want to assign Carl here to the project and you'll have him get an email.<br>18:18 So let's look at what we need to do for that. We want to copy this send review email function Understand how to create and use functions in Google Sheets. Opens in new tab and we'll edit this.<br>18:27 So instead of send email we'll send a signed email. We want to make sure that the column edited is the third column.<br>18:36 So we're and the edit value is going to be different each time so I'm gonna just delete that for right now.<br>18:50 And inside of here I'll say another if if edit value is equal to Carl we'll do something.
And then same but if, who's the other name, uh Ben.<br>19:09 So depending on who it is assigned to I'm gonna do something. Umm and that's the only options I want to give it.<br>19:18 I don't want anything else to happen. So, we are going to take this whole email and we will send an email but we're just gonna edit the email a bit.<br>19:31 Let's format Learn tips for formatting your sheets to enhance readability. Opens in new tab this well. There we go. Okay. In this one we want, hey Carl you've been assigned. Assigned. Signed project.<br>19:46 We have the project name as well. We want the two to be someone else.
So, I'm going to put my own email here.<br>19:57 But this could be, you could type literally anyone's Carl's email right here. We need the URL, ah hey just you got assigned this project and check it out at this URL.<br>20:16 Same down here.
I'm going to use my own ehm- ehm- ehm ehm- ehm- ehm- ehm- ehm- ehm- ehm- ehm- ehm- ehm ehm- ehm-- ehm- ehm-- ehm- ehm- ehm- ehm- ehm- ehm- ehm- ehm- ehm- ehm- ehm- ehm- ehm- ehm- ehm- ehm- ehm- ehm- ehm- e And assign email, we need to go back to our triggers and add a new trigger Explore different types of triggers for automating tasks in Sheets. Opens in new tab .<br>20:48 Add a trigger Explore different types of triggers for automating tasks in Sheets. Opens in new tab , which function Understand how to create and use functions in Google Sheets. Opens in new tab to run, we want to send a signed email from spreadsheet Get familiar with the structure and features of Google Sheets. Opens in new tab and on edit. The good thing is that these uh, these edits, or these functions Get a comprehensive overview of functions available in Google Sheets. Opens in new tab will only run really, if the if statements are all true, if all of these are right.<br>21:08 So let's look. Let's assign Ben a project.
Ben's project. We don't need a status yet because it hasn't been started.<br>21:19 We hit, Ben. And now let's see if we get an email. We'll refresh. There it is. Already assigned project to Ben.<br>21:27 Ben's project. If we do this for Carl. Carl's second project. And assign it to Carl. Let's see if we get that email.<br>21:40 There we go. We got Carl's second project. So assign project to Carl. And now we have a link. So we can add interesting stuff here, right?<br>21:47 If we had more values Understand how to work with values and data types in Sheets. Opens in new tab , if we had more information, we could add it.
But the good thing is that we have this link to the sheet that this is being sent from.<br>21:56 So if Carl needs to update this, he can go and update it. To in progress. And if you if he needs a review, he can click needs review.<br>22:06 And we will get that reviewed. Email. There it is. Needs review. Carl's second project. So that's pretty cool. We've now created a completely automated project management suite with just a few.<br>22:20 Bits of code here. This is not that many less than a hundred lines of code.
And you can get the code right here.<br>22:27 If you're a member of better sheets, grab it right away. If you're not a member of better sheets and you're watching this somewhere else, uh become a bit, become a better sheets member and enjoy this automated project management code.</div>