<div>00:00 So this is a really cool use of
Apps Script
Learn about Google Apps Script and how it integrates with Google Sheets.
Opens in new tab
and Google Sheets to essentially create a database And then we're going to create our own API
where
Understand how to filter data using the WHERE clause in queries.
Opens in new tab
we're going to check the status of a job This is great if you're a prop managing projects if you're a product manager, and you want to Create essentially a place<br>00:18 on the web for someone to check certain jobs But you maybe give them an ID and you don't want them to see everything in the sheet So what you might be doing now is like using a couple of different Google Sheets and saying hey We'll we'll give you
import
Discover how to import data into Google Sheets from various sources.
Opens in new tab
range
Get to know how to define and use ranges in Google Sheets.
Opens in new tab
Or we'll give you some
filter
Learn how to filter data in Google Sheets for better analysis.
Opens in new tab
on this
data
Explore different types of data you can work with in Google Sheets.
Opens in new tab
<br>00:34 and trying to
hide
Find out how to format your data for better presentation in Sheets.
Opens in new tab
this
data
Explore different types of data you can work with in Google Sheets.
Opens in new tab
But this this way when we're gonna create an API and it's not as hard as you think because we're gonna Access Apps Script, and we're gonna create a do Get function here, which is built into Apps Script and gives us a lot of functionality, and we're gonna deploy a web app,<br>00:51 um it's really really quick, unbelievably easy, I'm gonna show you how to uh write this code and if you're watching this on bettersheets.co you can get this code down below, you can get this exact sheet.<br>01:02 But let me show you how it works first.
So we have two columns, a job and a status. We have IDs or we could have any text, any
unique
Understand how to extract unique values from a dataset in Sheets.
Opens in new tab
text here.<br>01:11 And this
unique
Understand how to extract unique values from a dataset in Sheets.
Opens in new tab
text is going to be read by our checker here, this is a uh card, I'm using C-A-R-R-D to create just a form online at an a URL uh and it's just a form that checks for this.<br>01:24 So we see job one over here, so let's look at for job one, check it, and what do we get in response?<br>01:30 So we got an
error
Learn about common errors in Google Sheets and how to fix them.
Opens in new tab
, it's actually because we're, we need to use incognito mode.
If we are the logged in user, it
sort
Discover how to sort your data effectively in Google Sheets.
Opens in new tab
of errors out, but this is great for giving access to other people, so we're gonna use an incognito mode right now, we're gonna enter job, and we're gonna hit check, uh and what the response<br>01:49 should be is done, right? And what does it give us? Up here you can see done. So, we go back, let's check
number
Get insights into number formatting and calculations in Sheets.
Opens in new tab
9, and the response should be in progress.<br>01:58 And so, let's see, does it do it? Yes, we get in progress. So now we can check jobs if we just know the ID.<br>02:06 We can also change this ID to something like, new job, or delta job, delta.
And if we enter delta, we just change the, we didn't change anything in the app, if we just change the sheet and the
data
Explore different types of data you can work with in Google Sheets.
Opens in new tab
itself, let's check for delta and see what we get in response.<br>02:24 We get in progress. See, it's checking the
data
Explore different types of data you can work with in Google Sheets.
Opens in new tab
live, and we've set up the API, we've set up the front end, and this is unbelievably easy.<br>02:31 We're just gonna do this in a few minutes. So let's get started. If you have never uhh used
Apps Script
Learn about Google Apps Script and how it integrates with Google Sheets.
Opens in new tab
before, this is a pretty advanced use of
Apps Script
Learn about Google Apps Script and how it integrates with Google Sheets.
Opens in new tab
.<br>02:40 Uh, and we need some
data
Explore different types of data you can work with in Google Sheets.
Opens in new tab
here. Uh, so follow along if you can.
If you haven't, take a look at, uh, spreadsheetautomation101 on bettersheets.co, or Master
Spreadsheet
Understand the structure and features of Google Sheets.
Opens in new tab
Automation, which includes, uh, uh, spreadsheetautomation101 and it gets you up to speed on
App Script
Learn about Google Apps Script and how it integrates with Google Sheets.
Opens in new tab
, but this video just shows you <br>03:00 a really cool example of it. So we're gonna go up uh, extensions
App Script
Learn about Google Apps Script and how it integrates with Google Sheets.
Opens in new tab
, and that's here. I'm just gonna rewrite this here again for you as I would write it myself.<br>03:08 Uh, and then we're gonna delete it. But we're gonna do
function
Learn about functions and how to use them in Google Sheets.
Opens in new tab
, do get, Hit.
This uh
function
Learn about functions and how to use them in Google Sheets.
Opens in new tab
is a built-in
trigger
Explore triggers in Google Apps Script and how they automate tasks.
Opens in new tab
, so we don't have to do anything.<br>03:17 We just need to make sure we get this correct that it's due get with capital G. We have the curly brackets as well.<br>03:22 Uh, and we need some input. So what this URL is doing, we're gonna, we're gonna deploy to a URL. Thank very much. This URL is we're gonna have some piece of
data
Explore different types of data you can work with in Google Sheets.
Opens in new tab
that is attached to that URL.<br>03:34 And that, in this case we're gonna call it e. We can call it anything we want. This, this is a variable we can call.<br>03:40 We can call this
data
Explore different types of data you can work with in Google Sheets.
Opens in new tab
or job.
But that might be a little confusing. So, I'm just gonna call it e.<br>03:46 This is very typical in
App Script
Learn about Google Apps Script and how it integrates with Google Sheets.
Opens in new tab
for event or shorthand for event. What we're gonna need first is a variable called job and we're gonna get e.
parameter
Understand parameters and how they are used in functions.
Opens in new tab
.job.<br>04:00 Why job here? Because we're gonna add to this URL, um, we're gonna add to the URL that we get, you'll see the API, uh, uh, uh, um, question mark job equals and then we're gonna have this check.<br>04:14 You'll see this later on.
Uh, what we need to do is we need to look for all of these statuses and say, hey, based on this
parameter
Understand parameters and how they are used in functions.
Opens in new tab
that we get, this variable, we need to go and get the status for it.<br>04:30 So we're gonna do const statuses. This is, we're just calling it statuses because it's all the statuses in one array,
spreadsheet
Understand the structure and features of Google Sheets.
Opens in new tab
app dot get
active spreadsheet
Learn about accessing the active spreadsheet in Apps Script.
Opens in new tab
.<br>04:40 Add once, if you're typing this yourself, uh add that you have to add these parentheses. Get sheet by name, we can actually put this on a new line.<br>04:48 And if we want, we're gonna do get sheet by name.
The name of the sheet we have here is statuses.<br>05:00 You can name it whatever you want. We're gonna call it statuses. is. And this allows us to get just that sheet.<br>05:07 We're gonna now get the last row of that sheet. Because we need to know how many things are in here.<br>05:15 Equals. Statuses. Which is this Peace. Variable right here. Get. Last row. That's all we need. Let's follow along here. Now we're gonna grab all the jobs.<br>05:32 We're gonna do exactly the same thing we did here with statuses but we're gonna get the jobs.
Thanks for And these are the job IDs or job numbers here.<br>05:41 And we're gonna add a little bit more but we're gonna do a
spreadsheet
Understand the structure and features of Google Sheets.
Opens in new tab
app. Get
active spreadsheet
Learn about accessing the active spreadsheet in Apps Script.
Opens in new tab
. We can use the uhh autocomplete here to do that.<br>05:51 Get sheet. Eat by name. We're using statuses. Same. We're also going to get the
range
Get to know how to define and use ranges in Google Sheets.
Opens in new tab
and the
range
Get to know how to define and use ranges in Google Sheets.
Opens in new tab
is going to start at column one.<br>06:08 Uhh sorry row one, column one, and it's going to go however many rows we have. So last row is our variable for last row.<br>06:17 And then we only want one column.
But what we need to make sure is in this array we get the
values
Discover how to work with values in Google Sheets.
Opens in new tab
.<br>06:26 Now we need all of the statuses. So this actually allows us the statuses, allows us to delete all of this, add statuses.<br>06:34 And there. That might be a little bit easier to read that we're grabbing the statuses page. We're getting the
range
Get to know how to define and use ranges in Google Sheets.
Opens in new tab
, the first uh, the first column up until the very last row and we're getting all the
values
Discover how to work with values in Google Sheets.
Opens in new tab
.<br>06:48 We can copy this and paste it and use it for status array. We can call this job.
I'll array or jobs, whatever we want.<br>06:58 And instead of getting the first column, we get the second column. So now we're getting both pieces of
data
Explore different types of data you can work with in Google Sheets.
Opens in new tab
. We're getting whichever column we want, which is the first column to look at what's the ID.<br>07:07 Then we're getting the
data
Explore different types of data you can work with in Google Sheets.
Opens in new tab
we want, which is the status as array. Okay. Now, we're going to create a little for loop.<br>07:15 We're going to create i equals zero. We're going to do i is less than jobs.length. Because we want to check through all of the jobs.<br>07:23 i++ because we want to iterate one time.
And each time we iterate we're going to say if jobs in brackets i, which is the way to indicate each line individually.<br>07:36 And if that's equal to job, meaning the
parameter
Understand parameters and how they are used in functions.
Opens in new tab
we got in the URL, well what do we want to do?<br>07:42 We want to say hey, give us a status. So, we do variable output equals statuses array i. So it's the exact same row as the one that's matching that job.<br>07:55 And now we go down to the bottom and we say return. And normal Oh no.
Basically in a
function
Learn about functions and how to use them in Google Sheets.
Opens in new tab
that we're writing in the
app script
Learn about Google Apps Script and how it integrates with Google Sheets.
Opens in new tab
without the do get if we're just creating a
function
Learn about functions and how to use them in Google Sheets.
Opens in new tab
we're just gonna say return output.<br>08:06 But we're using do get and we're gonna create uh basically an output text output to the web so we can't just return the output we need to do.<br>08:17 This uh a little bit something different which is content service.
Content service dot create text output and then put output in there.<br>08:29 So again normally a normal
function
Learn about functions and how to use them in Google Sheets.
Opens in new tab
in Google Sheets that stays in Google Sheets we wouldn't have to do this content service create text output but we have to do that now because we want it to go out to the web.<br>08:42 Okay I'm gonna delete all of this and we'll see if we made any errors here because we're gonna try this.<br>08:48 out we're gonna deploy new deployment we're going to
select
Understand the SELECT clause in queries for data retrieval.
Opens in new tab
myself to run it anyone can run it uh hit deploy we're gonna get a
unique
Understand how to extract unique values from a dataset in Sheets.
Opens in new tab
URL from this now now we have set up essentially an API that .
it exists on the cloud and it's this URL that allows us to uh uh access it so how do we test this we're <br>09:13 gonna go to postman and we're going to test this here in in future. And uh postman we have our URL this is our
web app URL
Learn how to deploy and access your web app URL in Apps Script.
Opens in new tab
and we want to test with a key which we've created the key here if you haven't noticed yet and maybe I didn't say it but job JOB this is the
parameter
Understand parameters and how they are used in functions.
Opens in new tab
we want to add to our URL.<br>09:35 So that's going to be our key.
We're going to write in job and what's the value let's do one this is the very first one we should get a status done now we can send that and we're should get a request a return back done perfect it's working absolutely perfectly now let's create a front end we're gonna<br>09:53 do that in card so in card all I have to do I'm using a blank thing here I'm gonna create a brand new one you see it here I'm gonna create a brand new one called a form we're going to
select
Understand the SELECT clause in queries for data retrieval.
Opens in new tab
the type custom we want to send to URL because our API is just a URL paste in exactly that same web app if you<br>10:16 lose it you can go back to deploy managed deployments this I think is the second It's just going to be a list of all of the deployments.<br>10:24 It's going to be a list of last one the latest one here if you lose it there it is we're going to change the method to get and then over on the
fields
Explore the concept of fields in data forms and APIs.
Opens in new tab
we want a enter job ID The 10.<br>10:40 text uh the type is going to be text ID again same
parameter
Understand parameters and how they are used in functions.
Opens in new tab
we've added here in our code JOB job that's going to add that job equals to the URL we're going to change the submit to You enter so you see which one of these is different we can actually delete this one and this is the one we are now checking<br>11:03 we hit done and all we have to do is save this
publish
Find out how to publish your Google Sheets and web apps.
Opens in new tab
it we're publishing it to a
unique
Understand how to extract unique values from a dataset in Sheets.
Opens in new tab
uh card sub domain you are more than welcome to page.<br>11:12 try it out yourself there or if you have your own website you can get it there so we have now updated our website there it is and again we are going to enter to let's say enter and let's see what But we get, we get done, perfect.<br>11:27 And if that, status has changed if
number
Get insights into number formatting and calculations in Sheets.
Opens in new tab
two is like hey umm review let's go back and see what that might look like now hit enter two wait for a moment ooh the you have the pay, so wait we're waiting and it is now review so now this is great we can create this API uh so quickly right less than fifteen<br>11:56 minutes this has been twelve minutes we've done this we now have an API that works it gets this
data
Explore different types of data you can work with in Google Sheets.
Opens in new tab
from the sheet what else how else can we use this well if we create a brand new sheet let's go sheet.new and we're like hey I want that
data
Explore different types of data you can work with in Google Sheets.
Opens in new tab
in the sheet I'm I don't want to use import range I don't want<br>12:12 to have any uh trace back to this sheet right Right?
If you use
import
Discover how to import data into Google Sheets from various sources.
Opens in new tab
range
Get to know how to define and use ranges in Google Sheets.
Opens in new tab
you have to um
allow access
Learn how to manage access permissions for your Google Sheets.
Opens in new tab
you need to show the URL of the sheet I don't want any trace of it but I don't want to have to do this front end kind of thing well what can we do we can do equals
import
Discover how to import data into Google Sheets from various sources.
Opens in new tab
data
Explore different types of data you can work with in Google Sheets.
Opens in new tab
and this allows us to<br>12:34 add a URL here and we're gonna do and b1 and we're gonna say if is blank b1 if it's Thanks for watching!
actually blank don't do anything but if it's not blank if there's something there then we're gonna add this exact this this URL we're gonna go to it we're gonna
import
Discover how to import data into Google Sheets from various sources.
Opens in new tab
that
data
Explore different types of data you can work with in Google Sheets.
Opens in new tab
we're gonna have to<br>12:58 add a question mark jobe equals and we're gonna look for the answer to that so right now it is blank Thank you. I'm gonna put in one it says loading there now I first this is similar to
import
Discover how to import data into Google Sheets from various sources.
Opens in new tab
uh
range
Get to know how to define and use ranges in Google Sheets.
Opens in new tab
I do have to
allow access
Learn how to manage access permissions for your Google Sheets.
Opens in new tab
but this is really cool because the URL that I'm using is not necessarily<br>13:19 connected to that sheet no one's gonna.
I'm gonna be able to know this script URL is connected to that sheet and now we have a checker right here so we can change this to two let's see that a load and it is in review so again we have a front end possible if we want to with card and using uh.<br>13:36 any kind of form and buttons here but over here on the left side we can put this into a goo sheet and create our own front end if we want to and we can hit delete and it shows nothing if we have forty five let's see it probably gives some kind of
error
Learn about common errors in Google Sheets and how to fix them.
Opens in new tab
.<br>13:52 an a so if we can always add on if and a around it and there we go or some message it might want some message not applicable might don't say instead of an
error
Learn about common errors in Google Sheets and how to fix them.
Opens in new tab
it's like not available.<br>14:08 available.
or not found. let's do that. now if we do four should show up. there you go. done. and we're done with our status job checker.<br>14:19 uhh this is really exciting. I really love this kind of stuff. umm we're using gucci tina coma completely new in different way.<br>14:26 I hope you enjoyed it.
if you are a better sheets member and watching this on better sheets then you can get down below if you're not watching this on better sheets.<br>14:31 uhh become a member and get the sheet or uhh this is probably going to be added on Udemy as well.<br>14:37 uhh but yeah if you're a better sheets member go and grab the sheet down below. you get this code written for you.<br>14:42 umm and the card is super simple. umm it is just a basic card with a form. there.</div>