Members-only tutorial
Watch the video and get the practice sheet with membership.
About this Tutorial
Sheet Resources
Video Transcript
<div>00:00 So Brendan was asking how to create a form programmatically we want to show how to create a form programmatically in this video I did show this off in a testimonial sheet video.<br>00:11 I did create before in this custom menu Learn how to create a custom menu in Google Sheets for easy access to your scripts. Opens in new tab We have create testimonial form and what that does is we can see here.<br>00:18 We can follow along item is create testimonial form, create form, and it does all of this stuff. It uses a form app, creates a new form, sets the title, sets required login false which is very important.<br>00:34 It then creates this sort Understand how to sort data in Google Sheets effectively. Opens in new tab of a title and then it creates text items.
It will, let's actually run this from the beginning.<br>00:48 Let's, let's create this from scratch but I want to use this function Discover the basics of functions in Google Sheets and how to use them. Opens in new tab on open in our sheet here. And I'll show you how to edit this, how to create it, and ultimately as a better team member you're happy to, you're more than welcome to copy the sheet.<br>01:05 Click below to copy the sheet. So we have a function Discover the basics of functions in Google Sheets and how to use them. Opens in new tab on open. This will get us the custom menu Learn how to create a custom menu in Google Sheets for easy access to your scripts. Opens in new tab . Create form menu I'll call it.<br>01:15 And then I'm just going to create a simple form called create form.
We'll use the same actually, we'll change this simple.<br>01:24 Alright, go back to our existing testimonial sheets. What I need to do here first, let's grab this line form app dot create.<br>01:34 We'll use that. So we'll do function Discover the basics of functions in Google Sheets and how to use them. Opens in new tab create simple form. The first thing we need is a variable form equals form app dot create new form.<br>01:50 This doesn't matter. Set the title as simple form set required login false. That is very important. That's the next thing we need.<br>02:00 We have this site name. And we don't need this in our case.
We do want to add a text item set title.<br>02:06 So we'll do that form dot add text item set title. Title of simple form. We'll do that. What's next? Next we want to, okay, next is very important because we need to set the destination of the form to the sheet that's creating it.<br>02:31 If you happen to go up to tools, create a new form, this automatically creates the form and sets the responses to this sheet.<br>02:41 We programmatically do this through app script Explore Google Apps Script to automate tasks in Google Sheets. Opens in new tab , it doesn't do that automatically.
So we, what we need to do is we need to get the spreadsheet Get familiar with Google Sheets and its features. Opens in new tab app dot get active spreadsheet Learn how to reference the active spreadsheet in your scripts. Opens in new tab , get the ID of this entire spreadsheet Get familiar with Google Sheets and its features. Opens in new tab file.<br>02:52 Then we're going to grab the form app that destination type and call it and say this spreadsheet Get familiar with Google Sheets and its features. Opens in new tab . This is the spreadsheet Get familiar with Google Sheets and its features. Opens in new tab .<br>03:01 Sheet that you go to. This is the sheet ID Find out what a sheet ID is and how to use it in Google Sheets. Opens in new tab that you set and it sets the form set dot set destination here.<br>03:09 So that is important to do. And now we need to quote unquote open this and create some items.
In this case where Understand how to use the query where clause in Google Sheets. Opens in new tab in our testimonial example we wanted to ask people, the questions we asked them was what's your name, what's your role, what's your company.<br>03:28 But I want to do something a little bit different. I want to ask what is your name. Maybe we do item dot add text item set type.<br>03:41 It'll what's your email. Then what else do we need to do. We do not need this other stuff. Well actually this is really helpful.<br>03:59 We will grab this and use this again. So what this is doing is saving the ID of the form to a settings page.<br>04:14 Actually we don't really need that.
We don't need any of this. Maybe we want to get the- URL of the form.<br>04:26 Hmm. Let's do with audit right now. Let's actually do without it for right now. Okay, save. We're just doing command s saving this.<br>04:39 Now what I'm going to do is I will refresh this page. So that our custom menu Learn how to create a custom menu in Google Sheets for easy access to your scripts. Opens in new tab shows up. You must save.<br>04:48 If you do not save and you refresh it, then your app script Explore Google Apps Script to automate tasks in Google Sheets. Opens in new tab is going to be unsaved. So we have this create form menu.<br>04:54 Let's see if this runs. We will need to do authorization Learn about authorization in Google Apps Script for accessing user data. Opens in new tab the first time it runs.
I do believe it might work the first time though.<br>05:02 We will see if it works or not. See the end result. Just approving the authorization Learn about authorization in Google Apps Script for accessing user data. Opens in new tab . And I don't think it worked.<br>05:10 So let's do it again. Run the script. And we should have form responses here. Perfect. Finish the script. And it has your name, your email.<br>05:21 Let's look at it. I think we can see extensions. Manage form. It's already here. Edit form. See, we did not have to go up to tools.<br>05:33 Create form. We had to go up to our custom menu Learn how to create a custom menu in Google Sheets for easy access to your scripts. Opens in new tab here. And it is correctly titled Simple Form.
We have a text item.<br>05:47 That's probably not what we wanted. So we can edit. Let's edit that out. Let's go to extensions, app script Explore Google Apps Script to automate tasks in Google Sheets. Opens in new tab . We have set title.<br>06:01 I wonder if we can, Just do this. Title of simple form. Actually, we don't need that at all. We need this set title.<br>06:17 Oh, this title we do not need at all. So wait, we just have a form. Set the title. The first time this form is used, the set destination, it's also going to set the title and set required login to false.<br>06:31 I'll explain this in a hot second. Let's delete this form. How you do that.
If you have any mistakes in your form that's created, we have to go down here.<br>06:40 Unlink form. Click unlink. Then it will change this into a normal tab. We will delete this. It will also be in our drive.<br>06:52 You might want to move it to the trash. Might want to. Okay. Save all of this again. Let's try again.<br>06:59 We do not have to refresh it this time once we've edited some of that tech. Apps Script Explore Google Apps Script to automate tasks in Google Sheets. Opens in new tab . Let's create that simple form.<br>07:06 See if this, it will say to form responses to. We can always edit this later.
It's now asking your name and your email.<br>07:16 Let's go to tools, manage form, edit form. Great. We have a simple form title. We have your name. Does this work is the question and I know the answer is yes, but I want to show you why it's important that we have this set require login false.<br>07:39 Because when we're creating a form normally in settings. Responses and it will by default say restrict to users in my case.<br>07:50 I'm using better sheets workspace Google Workspace in your case. You'll have a different Google Workspace here.
It'll say restrict users to this.<br>07:59 This will be on if you create a new form. You have to turn it off in order for public people without a login to sign, not have to sign in and fill out your form.<br>08:11 If you want to do an event, community event, anything like that. So we have to go in here and do this manually, but programmatically doing it is just this dot set require login false.<br>08:23 That is it. And doing that allows our form to be used by people who are not in our organization, which is great.<br>08:30 Which is wonderful.
Most of the time we are using Google Sheets and Google Forms Discover how to create and manage Google Forms for data collection. Opens in new tab to gather data Understand data handling in Google Sheets and how to manipulate it. Opens in new tab from people who do not have access to our Google Sheets and Google Forms Discover how to create and manage Google Forms for data collection. Opens in new tab .<br>08:40 So that's great. Hopefully this was helpful to get you started. On creating a form programmatically, there are lots of things available in this form app.<br>08:49 I'll show you in Google where Understand how to use the query where clause in Google Sheets. Opens in new tab is it? Switch Learn how to use the switch function in Google Sheets for conditional logic. Opens in new tab my here it is. Google for developers. This is form app and it gives you a lot of options.<br>09:04 Of course, create the form, create checkbox validation Explore checkbox validation techniques in Google Forms. Opens in new tab , if you just want to checkbox Understand how to use checkboxes in Google Sheets and Forms. Opens in new tab instead of text.
Actually, sorry, that's validation Learn about data validation options in Google Sheets. Opens in new tab .<br>09:15 Set text item. Where Understand how to use the query where clause in Google Sheets. Opens in new tab is it? There it is, text item. And when you want to create a text item, it, where Understand how to use the query where clause in Google Sheets. Opens in new tab is it?<br>09:32 Set title, set required, set validation Learn about data validation options in Google Sheets. Opens in new tab , form.add text item, set title, all sorts of things here that are at your disposal to programmatically create.<br>09:46 Why would you want to do this?
Well, maybe I should have answered that in the beginning, but right now, really quickly I would say you want to create forms Discover how to create and manage Google Forms for data collection. Opens in new tab programmatically, especially if you're creating templates that you're selling, especially if you're creating lead magnets that you even give<br>09:59 away for free, but you want the ultimate user to create a form to gather information.
You're doing, like, I don't know, a referral workflow, or you're trying to help someone else who's going to create a form, say, each week or each month, and it has to be a separate new form, but it has all the <br>10:21 same information. It has all the same questions. It has the same order every single time and you want to create a brand new sheet, but you want all the same stuff in it meaning form, the form and the same questions, then creating it programmatically at the click of a button, like, literally<br>10:39 , for a user, one or two clicks, right very simple to set up.
For other users who are having to do this on either a weekly daily basis, maybe they do, you have a couple webinars a day you run and you're like, I wish I had a feedback form at the end of this to just give a link and I don't have<br>11:01 to, like, get the drop down validation Learn about data validation options in Google Sheets. Opens in new tab of which, for a which webinars did you show up to it's like, I want to create a brand new form for each and every webinar would be very useful for this kind of thing.<br>11:11 Alright, so hopefully this was helpful.
And again, if you're a BetterSheets member, you're watching this on BetterSheets, just go down below, you can grab this create a form programmatically sheet, which already has the app script Explore Google Apps Script to automate tasks in Google Sheets. Opens in new tab here written for you.<br>11:24 At least to get started. Thank you. Bye. Bye.</div>