Questions tagged [google-apps-script]

Use for questions about Google Apps Script, Google's server side Javascript-based cloud scripting platform for automating tasks across Google products and third-party services. Use in addition to relevant product-specific (e.g. [google-sheets], [google-docs]) or API-specific (e.g. [google-drive-api]) tags where applicable

Google Apps Script Logo

Google Apps Script is a server side Javascript-based cloud scripting platform for automating tasks across Google products and third-party services.

Here you'll find links to wonderful resources, helpful tips on asking better questions, and secret chat room links.


How to ask?

General information:
  • Well researched questions are better received by the community. You can start researching by reading or searching the issue in the official developer documentation and the FAQ. Don't ask questions because you want to know the answer, ask questions because you want others to know the answer!

  • Avoid asking questions that are goal oriented. Split up your goal into smaller questions and ask them one by one. For eg, avoid asking "How to create a Google sheet with sports information from this API?". Instead, start writing your code and if you run into a problem getting the correct information, ask "How to send the correct authentication request to this sports API using my username and password, as sending it directly gives me 404?". The latter is a programming question. The former is a business project. Asking volunteers to do unpaid work is frowned upon. See Why is "Can someone help me" not a actual question?

  • Always provide minimal reproducible example. The code should be as minimal as possible, preferably within ten to fifteen lines of code. This requires you to debug your code and takes effort on your part. You can start the process by "Starting from scratch". Don't start with where you are and start reducing. Start from scratch and start adding one by one. See minimal reproducible example.

  • If you reach this point and you are still struggling on how to fix / improve your first question, please read What is the proper way to approach Stack Overflow as someone totally new to programming?. You might also post a question on Meta Stack Overflow including a link to your post. If you get an error when trying to post to Meta, please checkout I'm asking a question about my own post, but I'm still prompted that I need 5 reputation to post here. What gives?.

Specific information:

Tag usage guidance

This is a summary of tags related to Google Apps Script and how to use them in the question being asked.


Community Chat Room

Note: Stack Overflow chat requires a minimum reputation of 20 or be "invited" by a Stack Overflow moderator.


Official Resources


Community Resources


Best Practices


FAQ:

:

53079 questions
68
votes
9 answers

Iterate over range, append string to each

I have a range of cells selected in a Google Sheets (activerange). I want to iterate over every cell in that range, and add a string to the end. The string is always the same, and can be hard coded into the function. It seems like a really simple…
ezuk
  • 3,096
  • 3
  • 30
  • 41
67
votes
2 answers

How to use "not" in Gmail filters?

I need to create a Google App Script to respond to machine generated emails, except those also sent to one colleague or contain a particular topic outside my responsibility. I've been trying to use the GmailApp.search API which includes all mail…
pterandon
  • 1,676
  • 1
  • 13
  • 15
67
votes
5 answers

How do I add formulas to Google Sheets using Google Apps Script?

How do I add a formula like: =SUM(A1:A17) to a range of fields using Google Apps Script for Google Sheets?
Pablo Jomer
  • 9,870
  • 11
  • 54
  • 102
66
votes
17 answers

Faster way to find the first empty row in a Google Sheet column

I've made a script that every few hours adds a new row to a Google Apps spreadsheet. This is the function I've made to find the first empty row: function getFirstEmptyRow() { var spr = SpreadsheetApp.getActiveSpreadsheet(); var cell =…
Omiod
  • 11,285
  • 11
  • 53
  • 59
66
votes
8 answers

How to define global variable in Google Apps Script

I see most examples from Google is they use only functions in a single giant script. e.g. https://developers.google.com/apps-script/quickstart/macros But in our style, we usually write all functions under a single namespace, such as MyCompany =…
Ryan
  • 10,041
  • 27
  • 91
  • 156
62
votes
6 answers

Get today date in Google Apps Script

How do I get the Today date on google appscript? I need to write a code to input today´s date in a cell. function changeDate(){ var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(GA_CONFIG); var date = //Today´s date!?!?!!? var…
user3347814
  • 1,138
  • 9
  • 28
  • 50
59
votes
3 answers

How to trigger a Google Apps Script once an email get in the inbox?

I have created a Google Apps Script that checks if an email has an attachment then send it to another email address. It's working fine, but I would like to create a trigger that would launch the script as soon as a new email arrives in the inbox. I…
AziCode
  • 2,510
  • 6
  • 27
  • 53
58
votes
5 answers

Script to Change Row Color when a cell changes text

I have a Google spreadsheet where I keep a list of bugs and whenever I fix a bug I change the status from "Not Started" to "Complete". I want to write a script for the Google Docs spreadsheet such that whenever I change the status to "Complete" the…
MadSeb
  • 7,958
  • 21
  • 80
  • 121
58
votes
3 answers

Collapsing Elements in a Google Doc With Google Apps Script - Is This Possible?

I'd love to be able to collapse and expand sections in my Google Docs document, making large documents easier to navigate. I was wondering if this is possible with Google Apps Script, or if I'd be wasting my time trying to find a way.
Squis
  • 921
  • 2
  • 8
  • 14
58
votes
4 answers

How can I test a trigger function in GAS?

Google Apps Script supports Triggers, that pass Events to trigger functions. Unfortunately, the development environment will let you test functions with no parameter passing, so you cannot simulate an event that way. If you try, you get an error…
Mogsdad
  • 44,709
  • 21
  • 151
  • 275
57
votes
6 answers

Create a new sheet in a Google Sheets with Google Apps Script

How to create a new sheet in a Google Sheets with Google Apps Script? I know it seems obvious but I just want to create a new sheet with a specific name.
Léo Davesne
  • 2,103
  • 1
  • 21
  • 24
57
votes
7 answers

Hidden field in a Google Form

I am adding a unique ID to each submission of the form. Right now, I made that ID the first field, and pre-filled it with the ID, along with a help text asking the user not to modify this field. Is there any option by which I can not show this…
Kira
  • 955
  • 1
  • 11
  • 25
56
votes
9 answers

How to create custom keyboard shortcuts for google app script functions?

I'm trying to get a sense of the viability of replacing some of my Microsoft Excel spreadsheets with Google Doc Spreadsheets. How can I create a custom keyboard shortcut to a google app script function in a google docs spreadsheet? This is…
User
  • 62,498
  • 72
  • 186
  • 247
55
votes
0 answers

Exceeded maximum execution time in Google Apps Script

I have an Apps Script that constantly gets this error. Judge by the notification email, it looks like the time limit is 5 minutes. Does anyone know if there is a way to extend this time limit? Or perhaps is there a way to call the Apps Script again…
Corry
  • 731
  • 1
  • 7
  • 8
54
votes
4 answers

Find Cell Matching Value And Return Rownumber

The employee sheet contains the name of the employee in cell C2. The name of the employee should also be on the data sheet in the range B3:B153. How can I get the rownumber of the cell on the data sheet that matches the employee name? I tried the…
LennartB
  • 559
  • 1
  • 5
  • 6