Google Apps Script is a lightweight, cloud-based tool used for automating basic office tasks. If your organization uses the enterprise version of G Suite apps, there’s no additional cost for using Google Apps Script. Essentially, they are small snippets of code used for adding custom integrations and functions into your G Suite applications.
When you open an Apps Script, a script editor appears on the screen. You can see the function pre-loaded on the screen that can allow you to start your work right away. All you need to do is to add the code according to your requirements. After publishing your code, you can also build webhooks with it.
Why Use Google Apps Script?
Google Apps Script is an excellent tool for users who are looking to customize their organization’s Google applications. It would serve you well if you want to automate basic tasks, fetch data from Google’s cloud ecosystem, get the most out of other G Suite apps, and share scripts with other users. The cloud script app allows many users to work with automation for the first time.
The platform’s script editor is compatible with JavaScript. You can use it to build a wide array of user interface elements, create alert dialogs and menus, and publish your scripts as web apps.
How Can You Use Google Apps Script?
There are a lot of possibilities with Google Apps Script. For instance, you can use it to automate the transfer of emails from Gmail to Drive, assign deadlines to tasks, and synchronize them with Google Calendar to receive notifications. If you know programming, then a lot of it comprises of “if-then-else” stuff to automate tasks. Similarly, you can also use it to automate the generation of QR code in Google Sheets.
Here’s a use case for Google Apps Script:
Consider that you work in HR for an organization, but your department is understaffed. Whenever a new hire comes in the organization, you make them register to your team via Google Forms. In this way, their information such as names, job designation, contact, and other details are collected. For convenience, you maintain the information of all employees in a spreadsheet. However, it can be quite challenging to manually transfer these details, especially due to your department’s lack of resources.
Enter Google Apps Script. You can use it to send a thank-you email to all the new applicants. Next, you can create another script to prioritize the ones with better skills, work experience, and qualifications. When an offer is accepted, you can use scripting to collect their data from the sheet and generate their new account.
In this way, you are bound to save a great deal of manual labor and time. Since everything was automated, all your data is accurate.
What If You Don’t Know JavaScript?
JavaScript is quite easy to learn even if you don’t have prior programming experience. In case you don’t want to write your own code, there are a lot of available apps scripts, allowing you to copy/paste codes for your tasks.
First Script in Google Apps Script for Mail
It’s easy to get started with Google Apps Script. Let’s go with a simple example. Your first script will send an email with a message to your Gmail account.
- Open Chrome or any other web browser and visit script.google.com.
- Log in to your Google account.
- After logging in, create a “New script”.
- In place of “Untitled project” enter the name “My First Script.”
Remove the existing code and type the following.
function SendinganEmailMessage() {
// Specify the recipient email address
var recipientEmail = 'abc1234@gmail.com'
// Write the email subject line.
var subjectLine = 'This is my first script!';
// Write the email body.
var body = 'This is the message';
// Send an email
GmailApp.SendinganEmailMessage(recipientEmail, subjectLine, body);
}
Save the code by clicking on the disk icon. Next, run the code by using the Run icon. For the first time, Google may ask for permission to run the script. You will see a warning if the app isn’t verified. Click on “Advanced’ and “Go to My First Script (unsafe)”. As you have written this script yourself, it’s safe to run.
Create a New Chart
Here is how you can use Google Apps Script to create a basic line chart.
function newChart(range, sheet) {
var sht = SpreadsheetApp.getActiveSheet();
var chtBuilder = sht.newChart();
chtBuilder.addRange(range)
.setChartType(Charts.ChartType.LINE)
.setOption('title', 'Line Chart for Product Trends');
sht.insertChart(chtBuilder.build());
}
Modify Chart
You can edit an existing chart by using the following code.
var sht = SpreadsheetApp.getActiveSheet();
var range = sht.getRange("C6:D10")
var cht = sht.getCharts()[0];
cht = cht.modify()
.addRange(range)
.setOption('title', 'Modified!')
.setOption('animation.duration', 700)
.setPosition(2,2,0,0)
.build();
sht.updateChart(cht);
Final Thoughts
Google Apps Script is an excellent tool for improving your productivity. Organizations all over the world are using it to simplify their workflows and reduce their burden from their staff. In case you want to use it for building charts, you can visit Image-Charts for more details.