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

Problem Solved. The problem is with string replace function in some other function. I am using the string replace function with regular expression as input to replace function. The regular expression was incorrect due which i am getting the above error. That’s really weird, at least GAS should give some proper error.

How do I use momentsjs in Google Apps Script?

Most people try to use the library with the key ending in 48. That library is pretty dated (it is version 2.9 which is pretty old). Using eval and UrlFetchApp.fetch moment.js or any other external library can be used easily in google app scripts. function testMoment() { eval(UrlFetchApp.fetch(‘https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.18.1/moment.min.js’).getContentText()); var date = moment().format(“MMM Do YY”); Logger.log(date) … Read more

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

from the documentation : Custom functions return values, but they cannot set values outside the cells they are in. In most circumstances, a custom function in cell A1 cannot modify cell A5. However, if a custom function returns a double array, the results overflow the cell containing the function and fill the cells below and … Read more

How to force newlines in Google Apps jsdoc descriptions

This method worked for me. In markdown (or in StackOverflow), you need to have two line breaks (ie an additional one) to start new line (or paragraph). same method worked for JSDoc /** * Converts the prefixed value to the specified base. * * Requires one of the following prefixes: * * ‘0b’ Base 2: … Read more

You do not have permission to call “UrlFetchApp.fetch”

onEdit is invoked by a Simple Trigger when a user changes a value in a spreadsheet. However, simple triggers cannot access services that require authorization, such as UrlFetchApp.fetch. See the Google Apps Script guide What you can do is to simply rename the function onEdit to something else, such as atEdit, so as to remove … Read more

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

Now it is possible to add time based events. from: http://code.google.com/googleapps/appsscript/guide_events.html Edit -> Current project’s triggers. You see a panel with the message No triggers set up. Click here to add one now. Click the link. Under Run, select the function you want executed on schedule. Under Events, select Time-driven. On the first drop-down list … Read more

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

There is no right or wrong answer. There are numerous factors to consider: If this is for/in G-Suite, then your G-Suite admins’ll have (or can get) access to anything. This may or may not be an issue. If you put the data in a sheet, anyone that has read access to the sheet can see … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)