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
54
votes
5 answers

how to unit test google apps scripts?

I'm trying to get set up with unit tests for google app scripts, and I found two projects: https://code.google.com/p/gas-unit/ https://code.google.com/p/gasunit/ So I'm confused which to use :-) I just had a go with the unhyphenated gasunit, which…
Sam Joseph
  • 4,584
  • 4
  • 31
  • 47
53
votes
2 answers

Sheet.getRange(1,1,1,12) what does the numbers in bracket specify?

Sheet.getRange(1,1,1,12) I cannot understand the arguments 1,1,1,12 . What is this - the sheet id or row or what? method getRange(row, column, optNumRows, optNumColumns) here what does optNumRows and optNumColumns mean???
52
votes
12 answers

Easiest way to get file ID from URL on Google Apps Script

Here is what I'm trying to do: given a Google document URL, I want to get the document ID to create a copy on Google Drive. I know I can achieve that by some regex or replacing on the URL, but as there are several different forms to represent the…
Renato
  • 685
  • 1
  • 6
  • 11
50
votes
7 answers

How can I create a hyperlink in the middle of cell text?

In google spreadsheets, it is possible to add a hyperlink to a cell as: =hyperlink("www.google.com", "search the web") This will show the text search the web which will hyperlink to google. However, I am wondering: How can this rule be inserting…
dublintech
  • 16,815
  • 29
  • 84
  • 115
49
votes
7 answers

Convert a Markdown text file into a Google Document using Appscript?

I am trying to migrate a load of documentation which was written in markdown into a Google Doc so it can be used by our marketing department. Is there a mechanism using appscript/ Google Docs Api that I can import a file and convert it to a Google…
UKDataGeek
  • 6,338
  • 9
  • 46
  • 63
49
votes
6 answers

Get Google Sheet by ID?

I know that Google Apps Script has a getSheetId() method for the Sheet Class, but is there any way to select a sheet within a spreadsheet by referencing the ID? I don't see anything like getSheetById() in the Spreadsheet Class documentation.
Finn Smith
  • 772
  • 2
  • 7
  • 21
49
votes
4 answers

Google Script to see if text contains a value

I have a google form that when the user submits it will trigger my function to run which is creating a summary of what they submitted as a Google Doc. I know it can automatically send an email but I need it formatted in a way that my user can edit…
Sharon
  • 493
  • 1
  • 4
  • 4
49
votes
2 answers

Debugging a custom function in Google Apps Script

I am trying to create my first custom function for a Google Spreadsheet in Apps Script and I am having a hard time using the debugger. I am working on the custom function demo code from the Google documentation and I have set a breakpoint in the…
48
votes
4 answers

How to use Utilities.sleep() function

What is the exact use of Utilities.sleep() function? Should we use it between function calls or API calls? I use the Utilities.sleep(1000) in-between function calls, is it right? Will it slow down the execution time?
balajiboss
  • 932
  • 2
  • 12
  • 20
47
votes
2 answers

How to use UrlFetchApp with credentials? Google Scripts

I am trying to use Google Scripts UrlFetchApp to access a website with a basic username and password. As soon as I connect to the site a popup appears that requires authentication. I know the Login and Password, however I do not know how to pass…
45
votes
2 answers

"function not found" error when making both GET and POST requests to a Web App

I'm getting a Script function not found: doGet OR Script function not found: doPost when I GET/POST to my Google script: function doGet(e){return ContentService.createTextOutput("User says")} function doPost(e) { return…
echan00
  • 2,788
  • 2
  • 18
  • 35
45
votes
11 answers

Script runtime execution time limit

My Google Apps Script is iterating through the user's Google Drive files and copying and sometimes moving files to other folders. The script is always stopped after certain minutes with no error message in the log. EDITOR's NOTE: The time limit…
44
votes
5 answers

Google Form API?

I would like to (programmatically) convert a text file with questions to a Google form. I want to specify the questions and the questiontypes and their options. Example: the questiontype scale should go from 1 to 7 and should have the label 'not…
Cie6ohpa
  • 815
  • 1
  • 10
  • 13
44
votes
7 answers

Timezone conversion in a Google spreadsheet

I know this looks simple. In a Google spreadsheet, I have a column where I enter time in one timezone (GMT) And another column should automatically get time in another time zone(Pacific Time) GMT | PT ----------|------------ 5:00 AM | 9:00…
SangyK
  • 799
  • 2
  • 6
  • 16
44
votes
5 answers

How do you do dynamic / dependent drop downs in Google Sheets?

How do you get a sub-category column to populate a drop down based on the value selected in the main category drop down in google sheets? I googled around and couldn't find any good solutions, therefore I wanted to share my own. Please see my answer…
tarheel
  • 4,727
  • 9
  • 39
  • 52