Automatically Timestamp New Tasks When Entered
Learn how to automatically timestamp new tasks in Google Sheets using the onEdit function in Apps Script. This video guides you through the process of setting up a timestamp for each new entry in your task list.
We're entering tasks into a sheet and we want a time stamp when we enter it. So we want to go into a task column. Go to the bottom, type in new task. And the moment we enter that, we want a time stamp here, right? We want to know when did we enter it. I'm going to show you that in this video. I'm going to go to extensions appscript. We're going to create a function here called onedit. Now this onedit is actually a built-in function . We just have to type it in with a capital E. Make sure you have that. And we're going to use an event here. Here we can actually make this just E, but it's just like a variable. It says anytime there's an edit, it's going to have some interesting information. For example, we can know what row we're on. Go E. range .get row. We know what column we're in. E.trange.getc
column. And we'll know the actual sheet we're on. Active sheet by spreadsheet app.getactive get active spreadsheet get active sheet get name and so we'll get the name of whatever the active sheet we're on and in our case it's called tasks so we'll go back here and we'll say if active sheet is equal to that's two equal signs tasks then we'll do something but we need one more thing here which is we want to make sure we're in the first column so we'll do double amperand which means and column equals equals 1 and that should be two equal signs and both of these must be true. We must be editing whatever we are doing on
the tasks tab and in column one. Let's call this time stamp. And what are we going to do here when we do that? Well, we're going to go spreadsheet app.get active spreadsheet get sheet by name tasks. That's a sheet we're on. Get range . And the range is going to be whatever row we're on. the second column and a cell size of one by one. Set value new date and we're going to put in new lowercase space capital D date. Let's save this. Go back and enter something new. And there we go. We have our time stamp. We have a date and a time here. So, we can say even newer. And there we
go. That's two different times slightly but the same day. We can format this any way we want. We can say format number and we can go to custom date and we can say let's get the whole written out one. There we go. And we can format it that way. But the underlying data is going to be a time stamp, a date and a time which is pretty cool. Even if we come in here and edit this, write meeting agenda today, we're going to get a time stamp of whenever this is last edited or even if we delete it, it'll show up. So maybe we want to get an old value variable old value is equal to e old value. Perhaps we want to add that only when we add new. So the old value
is equal to nothing blank. not when we edit it and not when we delete it. Perhaps we want to do that. That's a sort of an optional thing we can do. So now editing fix broken homepage URL that will not get a time stamp but adding a new or task get new link we can add here or old value is equal to null. We just need these parentheses deleted. And now we can get new link and that'll work now. So this old value is just a property of E. We don't have to have the parenthesis here. If you're interested in getting this automation plus a whole lot more, let me introduce you to sheet ops. This is a fully configured automated task
manager, business operation, command center where you can assign tasks to yourself in Google tasks and to others with Google calendar. We have lots of options here. You can even quickly email people, WhatsApp them, Telegram them. Keep on top of tasks of which you're accountable but maybe not responsible, but also those tasks that you are responsible for. Put all of your tasks in here and let sheet ops let you run your business operations like you never have before. Get sheet ops. I'll put the link down below. You're watching Better Sheets here on YouTube. Make sure you check out this video or this video and subscribe right now to get more tips, tricks, how-tos, get more out of your Google Sheets than you ever have before. I'm excited to be making a ton more
videos here. Ask me questions down in the comments and I will answer them in future videos. But for right now, right here, one of these videos is going to be your next Google Sheet.