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
167
votes
13 answers

How to debug Google Apps Script (aka where does Logger.log log to?)

In Google Sheets, you can add some scripting functionality. I'm adding something for the onEdit event, but I can't tell if it's working. As far as I can tell, you can't debug a live event from Google Sheets, so you have to do it from the debugger,…
d0c_s4vage
  • 3,947
  • 6
  • 23
  • 32
164
votes
7 answers

How to number the headings in a Google Docs/Drive document?

Is it possible to number the headings in a Google Docs/Drive document?
ZehnVon12
  • 4,026
  • 3
  • 19
  • 23
155
votes
3 answers

How to get the correct range to set the value to a cell?

I want to set text or number in Google Sheet from script. I want to set Hello or number 9 in cell F2. I found this code so far: SpreadsheetApp.getActiveRange().setValue('hello'); but that doesn't specify which cell.
user635600
127
votes
24 answers

Convert column index into corresponding column letter

I need to convert a Google Spreadsheet column index into its corresponding letter value, for example, given a spreadsheet: I need to do this (this function obviously does not exist, it's an example): getColumnLetterByIndex(4); // this should…
BeNdErR
  • 17,471
  • 21
  • 72
  • 103
124
votes
22 answers

Refresh data retrieved by a custom function in Google Sheet

I've written a custom Google Apps Script that will receive an id and fetch information from a web service (a price). I use this script in a spreadsheet, and it works just fine. My problem is that these prices change, and my spreadsheet doesn't get…
tbkn23
  • 5,205
  • 8
  • 26
  • 46
119
votes
7 answers

How to union ranges in google spreadsheets

I want to union ranges from any Google spreadsheets. The example Sheet1!A:A {12, 131, 45} Sheet2!A:A {12, 131, 46} The unknown function =formula_for_union_range(Sheet1!A:A; Sheet2!:A:A) should return {12, 131, 45, 12, 131, 46} The question How…
113
votes
24 answers

Selecting the last value of a column

I have a spreadsheet with some values in column G. Some cells are empty in between, and I need to get the last value from that column into another cell. Something like: =LAST(G2:G9999) except that LAST isn't a function.
111
votes
8 answers

Convert Unix Epoch Time to Date in Google Sheets

I have a sheet with a column of unix epoch times (in seconds): 1500598288 How can I convert these into normal dates?
Mike Bjorge
  • 1,941
  • 2
  • 11
  • 13
111
votes
10 answers

Printing to the console in Google Apps Script?

Back in 2012, I had some Google Apps Script code for a poker game: function addplayerstoArray(numplayers) { var playerArray = []; for (i=0; i
jim_shook
  • 1,245
  • 2
  • 9
  • 9
105
votes
30 answers

Determining the last row in a single column

I have a sheet with data in cols A through H. I need to determine the last row in column A that contains data (it's all contiguous - no gaps in the data/rows). There is also data in the other columns that have more rows of data than column A, so I…
5th4x4
  • 1,497
  • 8
  • 21
  • 27
79
votes
5 answers

Should Google App Scripts be stored in version control like GitHub

I am confused about the best way to manage shared development of Google App Scripts. The thing is that editing google app scripts is done through an online editor with its own version control in place, but that's not shared with other developers as…
Sam Joseph
  • 4,584
  • 4
  • 31
  • 47
75
votes
1 answer

Is it possible to 'prefill' a google form using data from a google spreadsheet?

I'm looking for a way to 'pre fill' a google form with specific data from a google spreadsheet. The form will have the same 'standard' questions for everyone, but the data in the first two question will be 'prefilled' with unique data from an…
Mr. B
  • 2,677
  • 6
  • 32
  • 42
72
votes
5 answers

How do you add UI inside cells in a google spreadsheet using app script?

I'd like to add buttons to specific cells in Google docs spreadsheet. The apps script UI documentation talks about how to add a new panel, but it's not clear how UI in that panel could be attached to specific rows or cells. Is it possible to add…
James Moore
  • 8,636
  • 5
  • 71
  • 90
71
votes
3 answers

Get Sheet By Name

I'm trying to get the following formula to work: function setDataValid(range, sourceRange) { var rule = SpreadsheetApp.newDataValidation().requireValueInRange(sourceRange, true).build(); range.setDataValidation(rule); } function onEdit() { …
Michiel van Dijk
  • 783
  • 2
  • 8
  • 19
69
votes
3 answers

How do I locate a Google SpreadSheet ID?

https://developers.google.com/apps-script/guides/rest/api#parameter_and_return_types When using the Google Execution Api for Java, the ID of the spreadsheet isn't very easy to understand. Here is the code snippet: // Initialize parameters for that…
RamelHenderson
  • 2,151
  • 2
  • 13
  • 12
1
2 3
99 100