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
38
votes
10 answers

How do you create a "reverse pivot" in Google Sheets?

I am trying to produce a "reverse pivot" function. I have searched long and hard for such a function, but cannot find one that is already out there. I have a summary table with anywhere up to 20 columns and hundreds of rows, however I would like to…
38
votes
6 answers

Google Apps Script to open a URL

Is there a way to write a google apps script so when ran, a second browser window opens to www.google.com (or another site of my choice)? I am trying to come up with a work-around to my previous question here: Can I add a hyperlink inside a message…
PY_
  • 1,189
  • 8
  • 18
  • 29
37
votes
8 answers

How to parse an HTML string in Google Apps Script without using XmlService?

I want to create a scraper using Google Spreadsheets with Google Apps Script. I know it is possible and I have seen some tutorials and threads about it. The main idea is to use: var html =…
37
votes
2 answers

Google Forms file upload complete example

How do I allow my viewers to use Google Forms to upload some files to my form and save it to my Google Drive? I am looking for a complete example: It must tell what code to add to the example Google Form HTML source. How to use Google Apps Script to…
Tem Pora
  • 2,043
  • 2
  • 24
  • 30
37
votes
5 answers

How to get the current time in Google spreadsheet using script editor?

There is an option to write a script and bind it to a trigger. The question is, how to get the current time in the script body? function myFunction() { var currentTime = // <
J.Olufsen
  • 13,415
  • 44
  • 120
  • 185
34
votes
2 answers

How to declare a custom class in google scripts?

I want to create a class inside my script. Google Apps Script language is based on javaScript, so I took an example from a javaScript manual: class Polygon { constructor(height, width) { this.height = height; this.width = width; …
Ada Lovelace
  • 835
  • 2
  • 8
  • 20
34
votes
11 answers

What is the best way to parse html in google apps script

var page = UrlFetchApp.fetch(contestURL); var doc = XmlService.parse(page); The above code gives a parse error when used, however if I replace the XmlService class with the deprecated Xml class, with the lenient flag set, it parses the html…
copperhead
  • 647
  • 1
  • 9
  • 15
34
votes
5 answers

importing external javascript to google apps script

I am trying to use Trello from a Google Spreadsheet (Google Docs) and am not sure how to import/reference/link the javascript files required to use their library. My only other option is using their REST API directly (fine, but I'd rather use their…
dixkin
  • 811
  • 2
  • 11
  • 20
34
votes
7 answers

It it possible to change the from address when using sendEmail?

I'm wondering if there are any options for changing the FROM address of an email sent using MailApp.sendEmail. I've built a form that's published as a Web App. Students fill out and submit the form, and receive an email. I see how to change the…
Carrie
  • 1,037
  • 2
  • 12
  • 19
34
votes
10 answers

Write an array of values to a range of cells in a spreadsheet

Using Google Apps Script, is there a way to write the values in a Google Spreadsheet array to a range without looping? I am thinking something like the following to put one name each into cells A1:A3: function demoWriteFromArray() { var…
Playing with GAS
  • 565
  • 3
  • 10
  • 18
33
votes
7 answers

You do not have permission to call "UrlFetchApp.fetch"

I am sending http request from script editor in google spreadsheets, but I keep getting the following error message: Google Apps Script: You do not have permission to call UrlFetchApp.fetch. Required permissions:…
Haq Nawaz
  • 412
  • 1
  • 4
  • 12
33
votes
2 answers

What is the appropriate way to manage API secrets within a Google Apps script?

If I write a google apps script, and within the script I need to invoke third party APIs or make database calls, what is the appropriate way of managing secret API keys and passwords? Is there any risk in placing the secrets directly within the…
33
votes
3 answers

Is it possible to automate Google Spreadsheets Scripts (e.g. without an event to trigger them)?

Does anyone know if it's possible to use Google Apps Scripts to run without needed a manual event? Meaning - I would like to set up a spreadsheet to send a form every day at a specified time. I have figured out how to manually send the form by…
AJW
  • 331
  • 1
  • 3
  • 4
33
votes
6 answers

"We're sorry, a server error occurred. Please wait a bit and try again" error when running a function from a custom menu

I have received 341 error notification emails for the below error We're sorry, a server error occurred. Please wait a bit and try again. The notification email only tells about the name of function in which the issue is occurring. The script is…
MA1
  • 2,767
  • 5
  • 35
  • 51
33
votes
4 answers

Custom function throws a "You do not have the permission required to setValue" error

I am trying to set some value to a cell in a Google Spreadsheet: function exampleFunction() { var ss = SpreadsheetApp.getActiveSpreadsheet(); var sheet = ss.getSheets()[0]; var range1 = sheet.getRange("A1"); var value1 =…