IF formula is getting error in Google Sheets Script - google-apps-script

I tried IF formula in Google Sheets script like
=IF(D:D=False, "PAID", "NOT PAID")
but it's showing error.
Any other substitute formula for this condition?

What you are looking for is an array formula, which has nothing to do with Google Apps Script.
=ArrayFormula(if(D2:D=false,"Paid","Not Paid"))

Related

How to run a Google Sheets App Script, and if there is an error, then call Spreadsheet function IMPORTXML() instead to populate the cell?

To get the price of bitcoin and other cryptocurrencies into my Google Sheets spreadsheet, I use this function:
=importJSON("https://api.coingecko.com/api/v3/coins/markets?vs_currency=usd&ids=bitcoin","0.current_price")
where importJSON is a Google App Script provided by coingecko (see https://blog.coingecko.com/import-coingecko-cryptocurrency-data-into-google-sheets/ )
This works fine for a few lookups, but if the spreadsheet has many cryptocurrencies, a whole bunch of them will say "Error: Exceed maximum execution time (line 0)."
see picture
Is it possible to detect this error, and if there is an error, call this function instead:
=IMPORTXML("https://coinmarketcap.com/currencies/bitcoin","//div[#class='priceValue___11gHJ']")
The problem is that this is a Google Sheets function and I don't know how to call it from inside the Google Apps script inside the catch(err) code block.
See picture #2
You can do it wiht IFERROR
Sample formula:
=IFERROR(importJSON("https://api.coingecko.com/api/v3/coins/markets?vs_currency=usd&ids=bitcoin","0.current_price"),IMPORTXML("https://coinmarketcap.com/currencies/bitcoin","//div[#class='priceValue___11gHJ']"))

Get slicer value in Apps Script

I recently started using slicers in Google Sheets and I would like to find a solution (probably with Apps Script) to access the current value selected in a slicer of my Spreadsheet.
Do you have any leads to solve this problem?

Is there a way to make a google apps script always available? (google form/response sheet)

I have a google apps script that I use on the response sheet that results from a google form. I would like this script to always be available on any response sheet that gets created from a google form. I think I need to turn my script into an add-on, but I haven't found a simple explanation on how to do that.

Google Maps Xpath using Google Spreadsheet IMPORTXML

I am trying to use Pull data from google maps results using IMPORTXML function in google spreadsheet but I am getting error #N/A
=importxml(http://maps.google.com/maps?q=cosmetic+surgeon+NEAR+New+York%2C+NY%2C+United+States&output=classic&dg=ntvb,"//div[#class='name lname'])
or
=importxml(http://maps.google.com/maps?q=cosmetic+surgeon+NEAR+New+York%2C+NY%2C+United+States&output=classic&dg=ntvb,//SPAN[#class='pp-place-title'])
but nothing is working.. Any thoughts???
Thanks
If you're going to give importxml literal strings as arguments, they need to be double-quoted:
=importxml("http://maps.google.com/maps?q=cosmetic+surgeon+NEAR+New+York%2C+NY%2C+United+States&output=classic&dg=ntvb", "//div[#class='name lname']")

Google Script reading from a dynamic Google Sheet

I have a Google Script that reads from a Google Sheet. The only content of the Google Sheet is an importData() function that imports a CSV file. Will the importData() function in the Google Sheet be called every time the Google Script accesses the data in the Google Sheet? Or does the importData() function only get called when the Google Sheet is opened manually?
importData() is a formula, that is evaluated and reevaulated when a user opens the spreadsheet and when other cells that are referenced by the formula change.
So, this means the output of the formula is not available for Apps Scripts.
However, using Apps Script you can easily write the code to do what the formula does.
See this question for how to parse CSV data