Using Autocomplete in Google Sheets - google-apps-script

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.

Related

Auto-generation of a Google doc based on google sheets selection + additional data

Requirement: Auto-generation and completion of a Google doc based on selections made by filtering options in Google sheets
Step-by-step:
There are x options listed in a spreadsheet.
I reduce them to the number I need via filtering.
I then have these options + the expanded details automatically added to a google doc template I've designed.
As an unexperienced programmer, it's very likely that the most convenient way to do something like this is by using Google Apps Script as it has services that help to extend Google Sheets and Google Docs among other Google apps. This service use JavaScript as programming language and it's possible to create and manage the script by using a web browser.
Experienced programmers that don't want to invest too much time on doing this might also find convenient to use Google Apps Script, but they might prefer to use the tools used for other projects might use CLASP or the Google Apps Script API.
Besides using Google Apps Script this could be done by using Google Docs API, Google Sheets API, Google Drive API and Google Cloud.

How can I set an app script on a Google Sheet via the API?

Is there a way to set an App Script on a new Google Sheet via the Google Sheets API? We use pygsheets as our Python API Client for Google Sheets. Since we are using the onSelectionChange trigger to populate certain cells with a date, we would like to setup the app script after we have populated rows in the spreadsheet.
The Google Sheets API doesn't have a method to do this. You can use the Apps Script API instead, but there are a few caveats which may or may not work with your use case:
You can use projects.create to create a new Apps Script project and attach it to a Sheets file by specifying the parentId field, which is the Sheet's ID. However, there are no methods to attach a preexisting script to a Sheet. You can still use projects.updateContent to add the required script files, though.
You cannot unbind the script once it has been attached.
This API does not work with service accounts, and the user running it needs to explicitly allow it in their settings page. This is for security reasons, since allowing a malicious app to freely write scripts on your account could be catastrophic, but it adds more steps that your users would need to take in order to run your app.

Accessing linked Google Sheet cells from Google Apps Scripts

I am trying to develop a Google Document add-on to manage linked Google Spreadsheet tables in a Google Doc.
For example to allow updating of the source Google Sheet cells with changes applied to the linked cells of the Google Doc.
Although I can find the class list, there doesn't seem to the equivalent of an inlineLinkedTable class.
This post asks the same question but it wasn't answered.
What class should I be looking at or service.
Thanks,
Rob
It's not possible update Docs linked Tables from the API or Apps Script service.
There is a feature request asking for this feature to be implemented. You can click on the star next to the issue number to receive updates and to give more priority to the request.
Even thought you are using Apps Script in your example, this is also applicable to the DocumentApp service.

Take data from a Google sheet with Google App Script and organize it in a Google doc

In Sheets I have dates and events that I would like to publish in Docs with the events listed under MONTH - YEAR. The number of events can vary, though usually over 400 events over a 2 year period. Sheets has them all sorted, but I haven't programmed in JavaScript before as I have used Access to do this in the past (But it seems to be overkill to have Access just for this.) It seems that Google App Script is the only way to do it?
A sample of the Sheet is here https://docs.google.com/spreadsheets/d/1IYmdIZU9wEVgSr7l4UWzJE7xXgUEQQOHUVarBHCeWgI/edit?usp=sharing
A sample of the doc that I would like to make is here https://docs.google.com/document/d/1obF-OiRAQG_6WxwiCT5-GkvnjETsdYiMHB2SDGxDeKA/edit?usp=sharing
From the question
It seems that Google App Script is the only way to do it?
Besides Google Apps Script, there are APIs for Google Sheets and Google Docs that you could use with several programming languages. For more details see
https://developers.google.com/docs
https://developers.google.com/sheets

Is it possible to hide Google script from google sheet?

I have a Rest API available which I would like to make available via an Google sheet for less tech oriented people. I was wondering if it is possible to hide the google script from the sheet if I share it with people? I have some sensitive information in the code like the authentication etc which I would like to hide. Moreover, it would be nice if they can't infer with the code. Is this possible?
The only secure way is to create an add-on.
Related
How to protect the Apps Script code in a Google spreadsheet?