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
33
votes
6 answers

Compare two dates Google apps script

What would be the best way to compare two dates? var int = e.parameter.intlistbox; var startDate = rSheet.getRange(parseInt(int) + 1 ,1).getValues(); // returns Sat Jun 30 2012 00:00:00 GMT-0300 (BRT) var toDay = new Date(); // Sat Jun 23 2012…
Jacobvdb
  • 1,438
  • 1
  • 14
  • 28
32
votes
7 answers

How to convert Time into decimal float in Google Sheets using Script?

I want to convert the time HH:MM into H.xx Like I am getting it in this format: Sat Dec 30 00:00:00 GMT+05:21 1899 But this value is 04:29 in cell. I want it to be 4.5 hours to multiply it to hourly rate.
TheOnlyAnil
  • 877
  • 1
  • 15
  • 27
32
votes
4 answers

Import JSON data into Google Sheets

I am pulling data from a web service and it is formatted as JSON. I am writing a Google Apps Script for Google Sheets that will populate the data for me. My problem is, I can't seem to get it to parse out. Doing: var dataset =…
32
votes
6 answers

How do I use momentsjs in Google Apps Script?

I'm trying to utilize the momentjs library in Google Apps Script but I'm not clear on how to do so. I'm not sure how to add the library, so obviously running something like the following results in "Reference Error: 'moment' is not defined": var a…
Jared_C
  • 649
  • 1
  • 7
  • 16
32
votes
1 answer

Trying to read cell 1,1 in spreadsheet using Google Script API

I'm a mildly experienced programmer ... I have an OK understanding of OOP concepts, I've been using PHP and MySQL lately. I've started to dabble with Google API Scripts. I'm trying to write a very simple program to read cell 1,1 in a google…
Makonnen
  • 495
  • 2
  • 6
  • 8
31
votes
5 answers

How to enable autocomplete for Google Apps Script in locally-installed IDE

I'm trying to build GAS projects locally using clasp. Any locally-installed IDE is a huge improvement over Google's Script Editor, so the tool looks very promising. Unfortunately, the autocomplete feature for GAS services doesn't seem to be included…
31
votes
3 answers

Changing background color of specific cell on Google sheet

I am working on this script bound to a Google Sheets spreadsheet where I have this function running from a time-driven trigger. I would like to be able to target specific cells on the sheet (if the cell value = "Open") so that I can change the…
Dom
  • 313
  • 1
  • 3
  • 5
31
votes
1 answer

Set cell format with google apps script

It is possible to set number format to a cell with google apps script like cell.setNumberFormat("0.000"); I need to set cell format to a text, so that any date-like values were not automatically converted. How can I do this?
Mike
  • 20,010
  • 25
  • 97
  • 140
31
votes
5 answers

Set Timeout in Google Apps Scripts

Is it possible to call setTimeout or an equivalent function in Google Apps Scripts? When I try to run the following code: function onSubmit() { // we've been called, remove trigger, set timeout, re-enable, and then run function …
KyleMit
  • 30,350
  • 66
  • 462
  • 664
31
votes
5 answers

How to force newlines in Google Apps jsdoc descriptions

I can't figure out how in a Google Apps Script to display this correctly. I need it to display new lines in the jsdoc output(e.g. when the function tooltip window comes up in a Spreadheet functions.) I have tried html like however it is just…
masshuu
  • 471
  • 1
  • 4
  • 6
30
votes
3 answers

Google docs - Access text changes realtime

Goal Our users work in Google Docs. The text they write will be read to them as they type using text-to-speech. It should work across as many platforms and browsers as possible. Our solution This seems to fit the Google Apps Script, it works on…
30
votes
8 answers

Highlight entire row when cell is active

How to design a sheet script that would result in an active row being highlighted? I would like to have an entire row change color of font or background when one cell in that row is active. I don't want the trigger to be any specific value in the…
Shawn Hamilton
  • 309
  • 1
  • 3
  • 3
30
votes
5 answers

Format a Google Sheets cell in plaintext via Apps Script

Using Google Apps Script, I want to set the format for a Google Sheets cell to plain text. The reason I want to do this is because I want to show a date in the U.S. date format (MM/DD/YYYY). [We can assume the locale in the OP's Google account is…
Anton Pil
  • 329
  • 1
  • 3
  • 7
29
votes
3 answers

For-each loop in google apps script

How do you create a for-each loop in Google Apps Script? I'm writing an email script with GAS, and I'd like to iterate through an array using a for-each loop, rather than a regular for-loop. I've already seen this answer, but the object is…
phlaxyr
  • 923
  • 1
  • 8
  • 22
29
votes
3 answers

How to use native spreadsheet functions in google apps script?

Is it possible to use native spreadsheet functions such as sum() or today() in google apps script, when writing code for google Spreadsheet? If so, how do I do it?
user3347814
  • 1,138
  • 9
  • 28
  • 50