Create Basic Google Sheet Addon Using Google Apps Script

In our previous article we learn that How to Write Google Apps Script? you can check that if you missed it. With the help of G-Scripts you can develop a Google Web App or Add-on Online.

By default, it’ll open with a single Google Script file (code.gs) and a default code block, myFunction():

function myFunction() {
 
}

In the code window, between the curly braces after the function myFunction() syntax, write the following line of code so you have this in your code window:

function myFunction() {
 Browser.msgBox("Hello World!");
}

Your code window should now look like this:

Next hit the run button (the black triangle), which prompts you to authorize the app to run, as shown in the following image:

Clicking Continue pops up another window in turn, showing what permissions your app needs to run. In this instance the app wants to view and manage your spreadsheets in Google Drive, so click Allow (otherwise your script won’t be able to interact with your spreadsheet or do anything):

UPDATE AUGUST 2017

Google have introduced new security protections to reduce risk from unverified apps, which affects the workflow when we first authorize our own apps.

When your first run your apps script, you may see the “app isn’t verified” screen and warnings about whether you want to continue.

In our case, since we are the creator of the app, we know it’s safe so we do want to continue. Furthermore, the apps script projects in this post are not intended to be published publicly for other users, so we don’t need to submit it to Google for review (although if you want to do that, here’s more information).

Click the “Advanced” button in the bottom left of the review permissions pop-up, and then click the “Go to Starter Script Code (unsafe)” at the bottom of the next screen to continue. Then type in the words “Continue” on the next screen, click Next, and finally review the permissions and click “ALLOW”.

Google Apps Script Tutorials ⟶

 

Written By:

Sarmad Gardezi A blog scientist by Mind and a Passionate Blogger by heart. Sarmad is Freelancer, Entrepreneur and Google Apps Scripts Developer from Islamabad, Pakistan.

Subscribe to Email Newsletter