Members-only tutorial
Watch the video and get the practice sheet with membership.
About this Tutorial
Sheet Resources
Video Transcript
<div>00:00 In this tutorial, I want to show you some really cool, simple inventory management automations that we can add. So this is a very simple inventory management.<br>00:09 We have items, a SKU number Learn how to work with numbers in your Google Sheets for better inventory management. Opens in new tab , stock. That's how many we have actually in our warehouse or storage. And then we also have a restock level here.<br>00:17 Ah, this is going to be used to compare to the stock and say, do we need to order now or not?<br>00:24 Ah, we can create some conditional formatting Discover how to use conditional formatting to highlight important data. Opens in new tab here. We're also going to create some automated emails and a last updated.
So there's going to be a lot of little scripts and some really cool automations of different varieties.<br>00:38 So first off, we can create a very simple status here. Do we need a restock or not? And we can say if stockLevel is equal is less than or equal to d, this restockLevel, then true is restockNow.<br>00:57 And if it's false, we can leave it blank, so we don't have to put anything there.
And now we can put everything, we can copy and paste this all the way down, but you see here it says restockNow, so we can also say if, we can wrap Find out how to wrap text in cells for better readability in your spreadsheets. Opens in new tab it around with isBlank d 2, and that makes sure that there's actually Yeah,<br>01:34 so now if there was zero here, we need a restockNow, or if there's one, restockNow. Cool. So, that's a first level of automation, we're using the if function Explore the use of functions to automate calculations in your inventory sheets. Opens in new tab , and also ifIsBlank, We wanna add a timestamp Learn how to add timestamps to track changes in your inventory. Opens in new tab here in column F, uh, also what column number Learn how to work with numbers in your Google Sheets for better inventory management. Opens in new tab is this, this is column 6. We wanna add a little timestamp Learn how to add timestamps to track changes in your inventory. Opens in new tab <br>02:09 there.
So, let's go up to extensions, Apps Script Get started with Apps Script to create custom automations in Google Sheets. Opens in new tab . We're gonna use the function Explore the use of functions to automate calculations in your inventory sheets. Opens in new tab onEdit, and we're gonna have E as an event here, variable row equals E. range Understand how to define ranges in your sheets for effective data manipulation. Opens in new tab .getRow, variable column equals E. range Understand how to define ranges in your sheets for effective data manipulation. Opens in new tab .getColumn.<br>02:36 Not sure if we're gonna need that yet. But on every edit, at least as long as it's on Sheet 1, and we'll call this stock.<br>02:48 Let me see. Variable stock equals SpreadsheetApp Learn about the SpreadsheetApp service for managing your Google Sheets. Opens in new tab .getActive. Spreadsheet Get familiar with the basics of Google Sheets and its functionalities. Opens in new tab .getSheetByName. Stock. So if, also we need variable sheet equals SpreadsheetApp Learn about the SpreadsheetApp service for managing your Google Sheets. Opens in new tab .getActive.<br>03:17 So if sheet is equal to stock, then we want to do something.
And we also need to make sure that it's row is greater than one, so it's not the head of row.<br>03:32 And let's say we only want stock updated. So if you update the SKU or your, update the item name or something else, we don't want to say that's updated.<br>03:41 So last stock update. So two ampersands and column is equal to, uh, three, because that's the stock column, three C.<br>03:57 All right, if that's true, if all those are true, what do we want to do?
Well, we want to do stock dot get range Understand how to define ranges in your sheets for effective data manipulation. Opens in new tab , we'll use the row and we'll put it in column six.<br>04:13 Only one size, we will set value to timestamp Learn how to add timestamps to track changes in your inventory. Opens in new tab . We will create a timestamp Learn how to add timestamps to track changes in your inventory. Opens in new tab just above it, variable timestamp Learn how to add timestamps to track changes in your inventory. Opens in new tab equals new time.<br>04:25 Date. We can format Discover various formatting options to enhance the appearance of your data. Opens in new tab this by wrapping this with utilities dot format Discover various formatting options to enhance the appearance of your data. Opens in new tab date, take this new date, time zone Understand how to manage time zones in your Google Sheets for accurate timestamps. Opens in new tab GMT, let's say plus six.<br>04:37 We can change that to whatever time zone Understand how to manage time zones in your Google Sheets for accurate timestamps. Opens in new tab you want. And the format will be, we'll just do the date, day, day, month, month, year, year, we can also.<br>04:49 But a time, if we want, we do need a parenthesis at the end of that.
Okay, let's save that and see if this works.<br>04:56 So if we change this five to a four, or this four to a three, we can see nothing happening. We can go back to our executions and see, ah, it failed for some reason.<br>05:09 Let's look at the error Learn how to troubleshoot common errors in Google Sheets. Opens in new tab code. We need some time to get the error Learn how to troubleshoot common errors in Google Sheets. Opens in new tab code. Maybe.<br>05:25 Ah, so what it says is, get column is not a function Explore the use of functions to automate calculations in your inventory sheets. Opens in new tab . It's a capital C. There we go. That is an easy fix.<br>05:34 Now, if we go three, So four here. Let's see if there's another error Learn how to troubleshoot common errors in Google Sheets. Opens in new tab code. Nope, this is completed. This is the third column.<br>05:45 Yep.
Oh, I think we need to- this should be stock, not this variable.<br>06:12 There we go. Now it should work. Alright, let's put this up to six, seven, ten. And there we go. We have all the timestamps writing there.<br>06:22 This is the last stock updated. This is- This is a date, and it's formatted as a date. If you want a time here, what we can do is actually not format Discover various formatting options to enhance the appearance of your data. Opens in new tab this at all. And let's delete.<br>06:34 All of this and just use new date. Simply that. And now let's look at what that does, is put a five there.<br>06:45 Now it has the time. So this is a whole time stamp.
If we- Do this to nine. As we sell things, we do that.<br>06:54 So this showed you that there's possibilities of automations with formulas and automations with the on-edit. But I want to show you one more cool thing which is adding a drop-down menu, not a drop-down menu, a menu.<br>07:07 But we go to better sheets at co slash snippets. And we scroll all the way to the bottom. Um It's also at the top, but this one is simpler.<br>07:16 Here's a custom function Explore the use of functions to automate calculations in your inventory sheets. Opens in new tab menu. So we're gonna add this above our on-edit. And we're just gonna paste this.
This is function Explore the use of functions to automate calculations in your inventory sheets. Opens in new tab on-open.<br>07:24 Again, a built-in function Explore the use of functions to automate calculations in your inventory sheets. Opens in new tab that just happens to trigger Explore how to set up triggers for automating tasks in your spreadsheets. Opens in new tab when the spreadsheet Get familiar with the basics of Google Sheets and its functionalities. Opens in new tab is opened. It's gonna get the UI, gonna create a menu called custom menu Find out how to create custom menus for easier access to your functions. Opens in new tab .<br>07:34 And we're going to have an item here. Well, What is this item we want to do? Well, we may want to control the input or output of this stock.<br>07:48 So instead of actually editing each of these cells Get to know how to manipulate cells for better data organization. Opens in new tab individually, maybe we want to just take a SKU number Learn how to work with numbers in your Google Sheets for better inventory management. Opens in new tab and say, we've had a sale. So, Sale.<br>08:00 So we're gonna call this, uh, had a sale. We're gonna go function Explore the use of functions to automate calculations in your inventory sheets. Opens in new tab , sale.
We're gonna create some ui here, which is, or ui, equals spreadsheet Get familiar with the basics of Google Sheets and its functionalities. Opens in new tab .get.ui, ui.prompt. And in this help, it actually shows uhh, uhh, gives us the code that we need.<br>08:28 So we can actually go to Google Help, Google Help, prompt, text, app script Get started with Apps Script to create custom automations in Google Sheets. Opens in new tab . And we can get close ui. Here we go.<br>08:45 And so this will give us a pretty simple, same thing, ui. Here we go. Button said yes no. We'll copy this over here.<br>08:57 We're gonna say, making a sale. What item did you sell? And we're gonna use a s skew.<br>09:17 We're going to get from this a response. So let's process the user's response.
Here, gets like the button. Did you make a sale?<br>09:27 What item did you sell? It'll, uh, have that as the response dot get response text. So we'll say variable skew e- equals response dot response text.<br>09:40 And here, we want to take out all of this log stuff. Basically, what we want to do is say, if we got a skew, find that skew here and update it here.<br>09:58 Just minus one. Okay. So we're going to get all of B column. So let's get the... this.<br>10:21 Get range Understand how to define ranges in your sheets for effective data manipulation. Opens in new tab . B colon B. Get values Learn how to work with values in your sheets for effective data analysis. Opens in new tab . For... actually, we'll create this called SKUZ. Variable SKUZ. Equals.
I equals zero, we'll say.<br>10:35 I is less than SKUZ. Length. I plus plus. So we're going to iterate through the entire list. So if SKUZ.I is equal to, the SKU that we entered, then we want, know that the I is the item that we want.<br>11:01 So we also want stock. Actually, we don't need stock. We don't need to do that. We do this. Stock.getRangeR Row is going to be I plus 1, and the column is going to be C, which is 3. Get value.<br>11:27 I'm going to say variable count equals this. And then we're going to take the entire thing again, and set the value, set, value count minus 1.
So this is going to be a little inventory system.<br>11:45 We can format Discover various formatting options to enhance the appearance of your data. Opens in new tab document to make it look a little bit prettier. Save it. We will need to refresh the sheet.<br>11:53 Now hopefully this works. Let's say we sold a mechanical keyboard. Look up here next to help. We have I'm gonna sail.<br>12:02 Oh, we will have the very first time we do this. We have to authorize it allow. What item do you sell?<br>12:12 We're gonna paste that skew number Learn how to work with numbers in your Google Sheets for better inventory management. Opens in new tab . And there it is. It minus 1. So we can do that. Let's say 3. Let's do that again.<br>12:24 Custom menu Find out how to create custom menus for easier access to your functions. Opens in new tab . You What item? Yes. There it is. Restock now.
So we have a conditional formatting Discover how to use conditional formatting to highlight important data. Opens in new tab . Uh, not conditional formatting Discover how to use conditional formatting to highlight important data. Opens in new tab .<br>12:37 Sorry. We have a formula Understand the syntax rules for writing formulas in Google Sheets. Opens in new tab which we might want to add conditional formatting Discover how to use conditional formatting to highlight important data. Opens in new tab . If this is restock now, um, we'll do that.<br>12:44 We have a time stamp with on edit. We have an on open automation with this how to sale. Now let's do conditional Discover how to use conditional formatting to highlight important data. Opens in new tab - a formatting Discover various formatting options to enhance the appearance of your data. Opens in new tab , format Discover various formatting options to enhance the appearance of your data. Opens in new tab , conditional formatting Discover how to use conditional formatting to highlight important data. Opens in new tab , apply to range, equal and e.<br>12:55 We're gonna say text contains restock now. And we're going to change this to red. Actually, we just need text is exactly restock now.<br>13:11 And all of those will turn red.
If we want the entire- Well, we need to do this. A colon f.<br>13:22 And then we need to change it to custom formula is Discover how to use custom formulas for advanced conditional formatting. Opens in new tab equal to e. Actually, ampersand e. One equals restock now.<br>13:38 In quotes. And now the entire row Learn how to format entire rows based on specific conditions. Opens in new tab will be highlighted because the range Understand how to define ranges in your sheets for effective data manipulation. Opens in new tab is a through f.
Actually, all the way up to f.<br>13:48 Uh, and then the custom formula Understand the syntax rules for writing formulas in Google Sheets. Opens in new tab , this dollar sign Understand the use of dollar signs in formulas for absolute references. Opens in new tab , e one, says no matter which cell we're in, look at the e column and look at the row we're on, which is this one looks like the number Learn how to work with numbers in your Google Sheets for better inventory management. Opens in new tab one, but it'll iterate through every single time, every single.<br>14:02 So we don't put a dollar sign Understand the use of dollar signs in formulas for absolute references. Opens in new tab there. Click done. We now have conditional formatting Discover how to use conditional formatting to highlight important data. Opens in new tab as an automation. And I want to show you one more thing which is a really advanced email automation.<br>14:16 Basically when this restock now shows up, we want to send an email to ourselves, let's say.
So let's go to App Script Get started with Apps Script to create custom automations in Google Sheets. Opens in new tab and start doing that.<br>14:26 So one note Explore how to add notes to cells for better context and information. Opens in new tab to say is we have now three automations. We have this on edit. We have sale, which is our, uh, prompt and we have on open.<br>14:37 If we're thinking about we want to make an email, send an email when this restock now happens. It's when this stock is updated, right?<br>14:46 But, unfortunately, email can not- not be sent through this on edit function Explore the use of functions to automate calculations in your inventory sheets. Opens in new tab . So you may think, originally, we just add it to this on edit, but we don't.<br>14:59 We're going to do it through a different on edit function Explore the use of functions to automate calculations in your inventory sheets. Opens in new tab .
So let's create some room down here and create a function Explore the use of functions to automate calculations in your inventory sheets. Opens in new tab email alert.<br>15:10 And we're going to do the same thing that we did on edit. I'm going to actually copy the whole thing.<br>15:18 And instead of creating a timestamp Learn how to add timestamps to track changes in your inventory. Opens in new tab , we want to make sure if we're on the stock page, we're on the third column.<br>15:27 Yes. And. So double ampersand. The. Stock level is less. We need. To do exactly this, basically. The stock level is less than or equal to the restock level.<br>15:45 So let's get our variable stock level equals and variable restock level equals.
We're going to do stock dot get range Understand how to define ranges in your sheets for effective data manipulation. Opens in new tab .<br>16:01 It'll be row column. Umm will be 3, 1, 1. Get value. Our restock level will be exactly the same thing.<br>16:14 We'll copy and paste it, except it's in the fourth column. And now, stock level is less than or equal to restock level.<br>16:24 So that's the only thing we have to add there. Those two. Two numbers. But now, we'll send an email. So, a very simple way to do this to just send an email to myself is mailapp Learn how to use MailApp for sending emails directly from your Google Sheets. Opens in new tab .sendemail.<br>16:37 And we need three things. We need someone to send it to. We need a subject and a body.
Our variable 2 will be equal, spreadsheetapp Learn about the SpreadsheetApp service for managing your Google Sheets. Opens in new tab .get... I don't know, I think it's just session.session.get.activeuser.getemail.<br>17:07 So, however the active user is right now, we'll get their email. Which, it'll be us most of the time if we're the only ones using this, um, spreadsheet Get familiar with the basics of Google Sheets and its functionalities. Opens in new tab . We can also get, owner Understand how to identify the owner of a Google Sheet for permissions. Opens in new tab , I think.<br>17:23 Yeah, this will be us, because we're gonna run this automation in a slightly different way than we're doing this on edit.<br>17:29 We want the variable subject, which we'll see soon. Subject equals restock needed.
And we wanna- maybe get the item name, so that's in the first column.<br>17:43 So let's call this variable item name, row one, or sorry, row, and then column one, and get the value of that.<br>17:57 We're gonna add that item name there. And the body variable body equals- You know what we'll do? We'll just do a link to this sheet.<br>18:07 That's it. Ah, we can say, go to this sheet to update stock. Plus sheet URL, we'll do a variable here.<br>18:26 Variable- sheet URL equals spreadsheet Get familiar with the basics of Google Sheets and its functionalities. Opens in new tab dot get active spreadsheet Get to know how to access the active spreadsheet in your Apps Script. Opens in new tab dot get URL. That should be it.
And we're going to send that email.<br>18:41 So how does this trigger Explore how to set up triggers for automating tasks in your spreadsheets. Opens in new tab , this email alert, we need an e here. By the way, what we're going to do is go over to this left side and, And go to, uh, triggers actually.<br>18:53 Not executions, triggers. We need to create a special trigger Explore how to set up triggers for automating tasks in your spreadsheets. Opens in new tab , add trigger Explore how to set up triggers for automating tasks in your spreadsheets. Opens in new tab , choose which function Explore the use of functions to automate calculations in your inventory sheets. Opens in new tab to run, email alert. From spreadsheet Get familiar with the basics of Google Sheets and its functionalities. Opens in new tab is correct, and it's not on open, it's on edit.<br>19:06 So this on edit allows us to use email. Essentially. Click save. We're going to authorize this again.
And this only happens when we need to set it up for the first time.<br>19:27 Make sure it's saved. There it is. It's running. We're going to edit this down to zero. We've sold all our monitors.<br>19:37 Let's look at our executions and see if there's any errors. It says on edit is completed. An email alert there completed.<br>19:49 No errors so far. And here's what the email looks like. It has the restock needed 24 inch monitor. That's the name.<br>19:57 Correct? Yes. And here's the URL of the spreadsheet Get familiar with the basics of Google Sheets and its functionalities. Opens in new tab they were on. Very cool. So that worked.
And that's an email alert based on an edit, basically.<br>20:09 This is really a clever way of getting these email alerts Discover how to set up email alerts for important inventory updates. Opens in new tab when something happens in the sheet. We just have to know like, when something happens what is that actual triggering thing?<br>20:21 Like, we know now it's editing this stock level, right? That's going to trigger Explore how to set up triggers for automating tasks in your spreadsheets. Opens in new tab it. But like, let's say- It goes 6, 7, we're ordering everything back to our things.<br>20:33 Is this going to trigger Explore how to set up triggers for automating tasks in your spreadsheets. Opens in new tab the email? Again, we can go over here and look at executions.
And we can see email alert is triggered and it's completed.<br>20:45 But let's check our email. So I just checked my email and I have not sent anything. Because we have that, One item in here, which says, look at the stock level, right?<br>20:55 We say stock level is less than or equal to restock level, then send us an email. So we need to make sure we know all of that.<br>21:03 So hopefully through this video you've seen some pretty simple automations all the way to something pretty awesome here.
Uh, if you're looking to get more out of Google Sheets, Make sure you take the course Master Spreadsheet Get familiar with the basics of Google Sheets and its functionalities. Opens in new tab Automation on BetterSheets.co. It's a combination of spreadsheet Get familiar with the basics of Google Sheets and its functionalities. Opens in new tab automation<br>21:26 101 and adventures in AI and some other courses. But on BetterSheets.co, check out Spreadsheet Get familiar with the basics of Google Sheets and its functionalities. Opens in new tab Automation 101 to get even more automations for your inventory.<br>21:37 Thanks for watching.</div>