How to validate addresses in Google Sheets? - google-apps-script

I'm trying to validate a list of addresses in a google sheet column, and create from it a well formatted new column(s). I came across the Google Maps Address validation API but I'm not sure how to use it or if there is another better solution out there.

Related

Using Autocomplete in Google Sheets

I want to create a spreadsheet where users can type an employee name into a cell on Sheet A, and they will receive autocomplete suggestions based on a list of employee names from Sheet B. This seems to be doable through data validation options but I want to do it through an Apps Script function. This seems to be straight forward but I'm only seeing how to do autocomplete projects on other Google platforms like WebApp.
This page has information about autocomplete but it doesn't have any examples about how that is used within Google Sheets specifically. Can this be done through 1D and 2D arrays within Google Sheets only?
Short answer: It's not possible to add an autocomplete to Google Sheets cells by using Google Apps Script.
The link about autocomplete included in the question is about Text Input widget from the Card Service. This service can only be used on Google Workspace Add-ons, not in "normal" scripts (https://developers.google.com/apps-script/guides/sheets).
Google Apps Script has simple and installable triggers but none of them could be used to do implement an autocomplete feature as can be done in Google Workspace Add-ons and in web applications.
You might use data validation and it's possible to set the data validations options by using Google Apps Script. Also adding the autocomplete entries in cells from the same column. You might hide the rows if you don't want to display them to the users.

search *somewhere* (Google Drive?) for Google Apps Script that contain search terms

I have many GAS that are bound to Google Sheets. I need to find the ones that reference certain search terms (FWIW, we're restructuring our BigQuery tables and I need to find out which ones reference the old table names so we can update them).
I've tried searching for the term in Google Drive without success.
I've tried to search for the term in the Apps Script Dashboard, but that only let's you search for project names.
And I did try to search in the Apps Script Dashboard using "type:script", but that doesn't let me search for any bound-script names, let along the contents of any bound scripts.
Is there a way to find/identify the scripts that reference "search term"?
Just as an example, if a bound script contains this code: var projectId = 'company-inventory';
I would like to be able to find that script by searching for "company-inventory".
Use the Apps Script API
It features the method projects.getContent that allows you to retrieve the content of an Apps Script with a known id programatically
You can programatically search within each retrieved project content for your key word
You can previously query for the ids of standalone script files with the Google Drive API list setting the q parameter to mimeType = 'application/vnd.google-apps.script'
Unfortunately the same does not apply for bound scripts - you can only retrieve the ids of those scripts from the Apps Script Dashboard

Google Apps Script: Get list of users "assigned" to a google doc and comments

In google docs, when commenting on something, you can type "+" to 'assign' a user to an item. I'm wondering if there's a way to get the list of "assigned" users in a google doc (and maybe filterable by status - resolved/done/etc).
I've seen some other posts stating that getting comment data isn't possible within the Documents Apps script, but that it is possible with the Drive API. Can the Drive API be used in a Google Sheets script? If so, could it be used to get the information mentioned above?
The Advanced Drive API can get a list of all comments in a spreadsheet but I don't think it will achieve what you are looking for as you can't tell which cell the comments are attached to.
I don't think you will be able to assess the assigned status using this method.

Why are there two different URL formats for Google spreadsheet documents?

My app accesses private Google spreadsheet documents on behalf of an authorized user. It seems that Google's API expects developers to first request a list of all the spreadsheet documents available to an authorized user before they can get at a particular spreadsheet's keys. I wanted to find a workaround to this, and eventually did by extracting the key parameter value from URLs spreadsheet URLs that look like this:
https://docs.google.com/spreadsheet/ccc?key={some long key here}&usp=drive_web#gid=0
It was simple enough to just break down the string to point where I could retrieve key's value fairly easy without the need of a regex.
Recently, though I don't know how recent, I notice URLs to newly created Google Drive spreadsheets come in this form:
https://docs.google.com/spreadsheets/d/{some long key here}/edit#gid=0
I was also able to extract the key from this URL string, but am just curious about the difference between the two URLs:
What is the significance between the two URLs.
Why does Google's API force devs to first get a list of all available docs, when a dev might just want to extract a key from a direct URL to a Google Drive spreadsheet doc.
Thanks!
Old style sheets
They work online only and limited to about 400,000 cells per spreadsheet.
Old style URL
https://docs.google.com/spreadsheet/ccc?key={some long key here}&usp=drive_web#gid=0
New style sheets
Released about mid Dec 2013
Works offline and (if I remember) up to 2,000,000 cells per spreadsheet.
https://docs.google.com/spreadsheets/d/{some long key here}/edit#gid=0
Spreadsheet KEY
I get the key using Google-apps-script, as described here:
Get the spreadsheet key that is in the URL. Not ss.getId()
Where are you getting the URL from? You shouldn't rely on specific URL formats, these are subject to change and not intended to be reliable. You should be able get just the id by specifying the "fields" parameter in your request. See https://developers.google.com/drive/v2/reference/files/list
Cloudward has solved this through Cloud Snippets. Here's two that may be of help, there are lots of others to explore as well.
Publish Simple List from Google Sheet:
https://snippets.cloudward.com/app_listing.espx?template_id=0d367025e8b5f402cd510905cade1d29&account_id=&cat_id=c478885bb325028151eaa9060422c67f
Publish Google Doc by ID:
https://snippets.cloudward.com/app_listing.espx?template_id=51925e7ed2166d7d83a8c32fa1ee88dd&account_id=
Hope this helps.
Bob

Google gadget/spreadsheet: Grab spreadsheet key for gadget

So I'm working on a google gadget(really only gadgetizing so I can get a datastore for this) that I want to be embeddable in a google spreadsheet (after this point, I'm going to skip the word google - you can just imagine it's there).
I want to use the spreadsheet that I embed the gadget in as a key/value store for the data I enter within the gadget (I think the 2K limit for gadget data won't be enough). It looks like what I'll want to do is use the gadget's feed api to manipulate the
spreadsheet's list feed. However, in order to know what the spreadsheet's list feed is, I need to know the key for the spreadsheet (which is in the URL). I don't think I can scrape the key directly from the URL, since the gadget seems to be inserted via iframe.
So I need to know how I can tell a gadget that I'm embedding in a spreadsheet the key for that spreadsheet. I suppose I could have the user enter it manually, but I'd much rather have my gadget know the key programmatically.
You might want to try using Google Apps Script instead of a gadget. It is aware of the spreadsheet it is embedded on.
http://code.google.com/googleapps/appsscript/
You should be able to retrieve a list of spreadsheets by making a GET request to this URL:
https://spreadsheets.google.com/feeds/spreadsheets/private/full
See Google Spreadsheets API for more details:
http://code.google.com/apis/spreadsheets/data/3.0/developers_guide_protocol.html#ListingSpreadsheets