Showing posts with label Javascript. Show all posts
Showing posts with label Javascript. Show all posts

Monday, June 05, 2023

Google Apps Script Annoyances

It appears as of June 5, 2023, GAS still does not support classes with private fields. Very annoying!!!

What are these private fields, see e.g. Mozilla Javascript documentation.

Apparently, the Google Chrome browser fully supports it since version 74 (Released 2019-04-23), which is curious!

Wednesday, October 26, 2022

Google Sheets Annoyances

I do some extensive Google Apps Script Javascript programming to manage my many Google Sheets spreadsheets. But I readily admit, I am not an expert senior or wizard programmer.

However, it is very irksome that you still can not directly and conveniently iterate over the cells contained in a range (like using the forEach()). Yes, you can easily iterate over the cell values of the range with the getValues() function. 

What if you need to do more with some of the, but not all of the cells contained in a range like formatting or clear the value etc.

So I had to write my own function to retrieve all cells as an array from a 1 dimensional range.

Wednesday, August 24, 2022

Google Apps Script annoyances

Yesterday, I was inundated all of a sudden and unexpectedly with a series of following error messages:

Error MessageCount
We're sorry, a server error occurred while reading from storage. Error code NOT_FOUND.12

This error message is as helpful as it can be! (Caution: irony)
I was running some scripts that have worked nicely for some time when this occurred.

Presumably, I had renamed a library or because some linked libraries were in development mode triggered these error messages. Renaming a library file should not affect such errors as Google Apps Script uses a unique identifier. 

Not only that, the last time I had renamed or linked such a library was several weeks ago and I have used the scripts several times since then without a glitch. Thus, it appears that Google does something that delays more timely errors.

Friday, July 22, 2022

Google Apps Script Annoyances

This is a very serious one and has bothered me many times now! If this happens, then it usually also wastes lot of your time to fix it.

If you add libraries (i.e. other GAS projects) to your current GAS project and an error occurs in one of your libraries, the error message does not reveal the name of the offending library, only the name of the script file and the line number. Well, you are lucky if you consistently use rather unique names for your script files.
This is very nasty!

Wednesday, May 11, 2022

Google Apps Script Annoyances

Yesterday, I discovered following:

  1. You create a new Date object DO in a function F1 located in the script project of a spreadsheet S
  2. Then you call a different function F2 with DO as an argument to process this date located in a separate script library L (not attached to any spreadsheet)
  3. The DO is not a Date object anymore when it enters the F2 function of L. To my surprise, a test like DO instanceof Date fails.
I have tried all kinds of ways to inspect the transferred object DO, but I was not able to determine how exactly this object is modified by Google Apps Script during this transfer or whether it is a general Javascript issue when transferring objects between scripts.

If Date object is indeed modified in some way while in transfer between two separate scripts, why is the Date object not reconstituted after arrival? In my opinion, this would be the correct way of doing it!

However, I was able to create a new valid Date object from the transferred object DO inside of F2.

Saturday, May 07, 2022

Google Apps Script Annoyances

Just discovered that String.prototype.matchAll() is not available!

That means among other things, JavaScript regular expressions with capturing groups is not available!

Very ugly!

Tuesday, April 19, 2022

Google Apps Script DocumentApp annoyances

It took me a few hours to determine that there is a character limit to how much text you can save in a document. The limit is currently around 1.5 million characters according to my experiments.

This critical limit is poorly documented if at all! It is certainly not mentioned in the reference documentation when you look up e.g. body.setText() or appendText().

This is the entire documentation for setText() method. The documentation for appendText() is similar.