Basic Google App Script for work

A simple tutorial for beginners with Google App Script

I. Introduction

This article is for people who wants to automate repetitive tasks and work smarter and faster in the 4.0 world. I will use simple words and explainations for readers. I think this will be a good tutorial for office staffs.

I will show you 4 jobs that Google App Script can help you in your work. I will notice every details you need to pay attention to. Before we start I have some things that you have to know.

First, I just show some simple codes you can use and if you want to customize it but you don't know how to write codes you can use AI. You can ask AI such as ChatGPT, Gemini to customize the code. However, you need to use suitable form and explain in detail for them. You can follow a method that I call "RICE":

  • Role: Give AI a role, like your assistant who fixs the code for you.

  • Information: Detail information about what do you want from the code

  • Context: What job do you do and the context of using that code

  • Example: Describe what you want to get such as: "After running the code, I can do A and then get B"

If there's any problems with code wrote by AI, you can take a screenshot to them and write a prompt order to fix that bug. Write detail prompts can be difficult for beginners, but you will get used to it soon.

Next, this is how you run an App Script and some small tips for you.

To run an App Script, click "Extensions" and choose Apps Script

In the above example, this will send mails to email in column B "Email address" with the content from "Email content". When you open App Script it will look like this:

Click "Run" to run the code.

Tips: The first time you run the code in the code editor the whole sheet must be blank because when run the code it create the "Send email" above and when click that it will send an email. But when you run in the code editor it will also send an email so at the first time it must be blank.

If your code have to get your permisson, it will show like this:

You just have to click "Review permissions"
If google show this, just click "Advanced"

After that just click "Go to [Project_name] (unsafe)" Don't worry, Google say that because they don't know the dude who wrote it. You can check the code again if you want, but all codes are safe.

Now you can start to know some examples for App Script (I know you won't read anything above and just see II. App Scipt usages first, if there's any bugs, you will comeback and read I. Instruction)

II. App Script usages

a. Automate email sending

You need 3 column like in the picture.

Every row in "Email address" is one email that google will send to. Like in the photo, after click "Send Email" it will send an email to [email protected] (That's our email too).

Here's the code:

You can see that the email is also formated as the original

b. Create repetitive reports or something like that

When you run the code, it will ask what week you want and ID of your doc files. You can create an original file with repetitive form

Just like this and coppy it into files then coppy their IDs.

Note: Write these phrases in places that will be replaced with information from the sheet.

c. Create Google forms

Create questions and answers, each row is an answer. Write [OPEN-TEXT-QUESTION] for open text question
Just edit a little bit, you'll have a complete form.

d. Create schedule on Google calendar

Create a menu like that with all columns
It can works very well

Here's the code:

And that's all things I want to share with you. I hope you can learn something to automatic your work.

- Pear -

Last updated