Why do my Google Sheet custom functions require this weird workaround? - google-apps-script

I’m creating custom functions in Google Sheets using their google apps script language. I’ve done my development on a laptop and it seems to work correctly.
However, when I open the sheet on my mobile device (iOS), the cell output for my custom functions get stuck at “Loading…” forever and never load. But I discovered this weird workaround, but I don’t know why it works or if there’s a better way: if I make a small, trivial change to one of the input cells, then close the sheet and reopen, the sheet will be correctly updated.
Note that if I just make a change to a cell, or add/delete a column etc, without closing and reopening, to force an update, it will still get stuck at “Loading…”.
Also note that if I close and reopen the sheet without making any change, it will still get stuck.
Any ideas of what’s going on here, and if there’s a better way to get my custom functions to correctly update without timing out?
I searched online for solutions, couldn’t find anything.
Update: Example sheet located at this link:
https://docs.google.com/spreadsheets/d/12nm9EwuzqaN0jYUv75CquMhrcUGlVsmEPFoWd92yuWo/edit
Look at the “SeasonTest” tab, cell AS5. On a mobile device it always shows “Loading…” (unless the above workaround is used), but works fine on a desktop

Related

Today custom function stops working in all google spreadsheets, any idea why? [duplicate]

I have a Google Apps Script custom function, very simple:
function sharesBurned(sharesToSell) {
return "tree"
}
Obviously, this works when I test it in Apps Script. In my sheet, when I call it in a cell, sharesBurned(2), for instance, it sometimes returns "Loading", and in the upper right hand corner of the cell, a red triangular sign appears that, when hovered over, reads: "Error - Loading data...".
I know there have been several threads on this, but they are pretty old, and I've tried all the suggestions already to no avail, namely:
Changing the function name
Refreshing the spreadsheet
Toggling Parameter Cell
Duplicating the spreadsheet
Clearing Browser cache / cookies
To be clear, the function loads in the cell seamlessly half the time and the other half is stuck like this. I highly doubt it's an issue with the script itself so this is likely some weird bug (caching? no clue) with Google Sheets.
This seems to be a issue on Google's server. There is already an active report about Google sheets custom functions stuck in loading. You may want to click the star icon on the top left of the issue report to indicate that you are also being affected by the issue.
Other related issues:
Apps script taking too much time to read from Google sheets
Apps script taking too much time to read from Google sheets charts

Loading... Forever [duplicate]

I have a Google Apps Script custom function, very simple:
function sharesBurned(sharesToSell) {
return "tree"
}
Obviously, this works when I test it in Apps Script. In my sheet, when I call it in a cell, sharesBurned(2), for instance, it sometimes returns "Loading", and in the upper right hand corner of the cell, a red triangular sign appears that, when hovered over, reads: "Error - Loading data...".
I know there have been several threads on this, but they are pretty old, and I've tried all the suggestions already to no avail, namely:
Changing the function name
Refreshing the spreadsheet
Toggling Parameter Cell
Duplicating the spreadsheet
Clearing Browser cache / cookies
To be clear, the function loads in the cell seamlessly half the time and the other half is stuck like this. I highly doubt it's an issue with the script itself so this is likely some weird bug (caching? no clue) with Google Sheets.
This seems to be a issue on Google's server. There is already an active report about Google sheets custom functions stuck in loading. You may want to click the star icon on the top left of the issue report to indicate that you are also being affected by the issue.
Other related issues:
Apps script taking too much time to read from Google sheets
Apps script taking too much time to read from Google sheets charts

Pasting data in multiple text boxes

So I have a zero-reporting data entry task which I do monthly. For a couple of cells, I have to enter zero manually (as shown in the image), which is very much frustrating.
Is there any web add-on I could use to paste zero in multiple cells at once?
Browsers only select text.
No way to select input-boxes (at least not yet).
I know what you are thinking.. Excel! Or Spreadsheets.
So.. unless the web-application you use, is rewritten to "mimic" spreadsheets (just like Google Sheets runs within the browser 100%)..
.. can't give you any hope.

Google scripts unhideRows not working

I have a script for Google Sheets I am working on. I realize there are better ways to do what I am attempting (cough html/database cough), but I am required to make this spreadsheet work.
In short, I am trying to hide and unhide rows dynamically. There does not appear to be a way to get filters to update without redoing them, so I am attempting to use hideRows to hide them and unhideRows to reveal them as needed.
The hideRows command works below. The unhideRows command does not. At this time, they are literally this close together in the code. Originally, I was hiding on one sheet and unhiding on another, but set up like this to troubleshoot. There is no filtering on this sheet (because it didn't work, I turned it off). I tried setting the value in unhideRows directly to the value tested instead of a variable.
The row in question hides, but does not unhide.
I tried unhiding a different row just in case google was fumbling with hide this, unhide it back to back. I am not getting unhide to work.
{ //thisRow = the row number of a range, in this case 2 if output to screen
pImages.hideRows(thisRow);
pImages.unhideRows(thisRow);
}
Apparently, the answer is not to unhideRows() which is the one the documents alluded to, but showRows () which does make more sense in everyday language. Thanks again to Mr.Houdini on the Google forums.

How to call a script in Google Spreadsheet above a frozen row?

Above a frozen row I want to put an image that is linked to a script; e.g. click the image and a script runs.
I can insert an image and add a script to it, problem: can only be
done under frozen row.
I can insert an image using =image("imageurl";2), I can even put a
hyperlink to this =hyperlink("url"; image("imageurl";2)) and this
works nicely but I can't call a script.
Any ideas on how to solve this?
How do you add UI inside cells in a google spreadsheet using app script? ... shows how to insert a drawing and link it to a script. Unfortunately, as you've found, floating images are not allowed in frozen rows or columns, so that technique breaks down if you must freeze rows. A quick search on the interwebs will show that this has been a long-term complaint about Google Sheets. (For instance.)
There are options, none of them ideal:
Use a custom menu function instead. That means users need to hunt a bit to find the menu option to kick your script, but it does stay in view no matter where they are.
Use the hyperlink & image work-around you've described, but use a published script url as the target. That will allow you to run a google apps script, indirectly.
Use a sidebar. OK, this isn't actually supported in Sheets yet - visit Issue 3162 and star it for updates.