Google apps script post-install tooltip - google-apps-script

I have created an add-on in Google Apps Script. There has to be post-install tool tip in add-on. The tool tip is seen at the add-on menu item after installation is complete. Could any one please tell me what is the method to do so or what is the exact procedure to show the tool-tip post install.

The post install tool-tip seen when installing an Addon is not built into the Addon itself, rather it's provided at the time that you publish the Addon. This isn't well documented however, merely lightly implied under 'Publishing instructions' -> 'Prepare and deploy your add-on' when it says 'In the Deploy as Add-on dialog, fill all required fields. The add-on’s name must be the same as the name of the Apps Script project. See the style guide for more information on the other fields.'
The Style Guide then has a section on the 'Post-install tip', implying that this is when it's filled. It could, however, be a lot clearer.

From the script you go to "Publish > Deploy as Docs add-on..." and from there you can add a Post-install tip.

Related

How can I "publish" an editor add-on to be used by just me?

I'm involved in a standards development group where the meeting invitations are sent out, not as calendar invites, but as Word docs. I've written a script that allows me to take the Word doc uploaded to Google Drive, and run the script to create an entry on a Google calendar that I maintain.
At the moment, the script is unpublished, and to run it on the docs I use the "Test as Add-On" function from the script editor. That's a bit cumbersome because I have to go through the selection dialog to select the doc I want to run it on. Additionally, in the new scripts editor, it won't be possible to delete old tests and so my test dialog will end up getting filled up with every run of the script I've ever carried out.
It would be much better if I could have the script available to me, and me only, from the Extensions->Add-Ons menu when I open a doc. The script is not suitable for general publication: it works only on docs with the exact format of these meeting notices, so it should only be run by someone who knows what they're doing, and it accesses a calendar that I own, so I don't want to make it public. But I would like to be able to put it into some kind of "deployed" state so that, as I say, when I open any doc when I'm logged in as me, the script is just available directly from the Add-Ons menu.
Is there any way to achieve this? Or is there an alternative approach possible to this general problem, of having a script that you want to run on multiple documents that you own without having to formally publish it?
One option to "test as add-on" without publishing the script as an editor add-on, is to use installable triggers instead of simple triggers. This triggers should be created by using code in order to avoid having to add any code to each spreadsheet.
If you are determined to take the publishing path you can set your add-on listing to be "unlisted", this means that the add-on will not appear on the Google Workspace Marketplace, people will need to know the installation URL to be able to install the add-on.
Other options:
If you have a Google Workspace account you could publish the add-on privately for your domain. If you don't have this account type or if this is "not good enough", you might make your Google Apps Script add-on publicly installable but limit its core features to be used only by you by making use of a dynamic custom menu. For details please checkout Editor add-on authorization
The dynamic custom menu might based on a setting depending on the user email address. To make this work, as the Session.getActiveUser() requires authorization to run, it can't be executed by simple triggers, but you might implement a workflow to save it or a flag, i.e. add an option to the custom menu to initialize the editor add-on.
Another option is to make the dynamic custom menu based on the spreadsheet structure and/or content.
References
Installable Triggers
Enable and configure the Google Workspace Marketplace SDK
Related
Google Apps Script: Dynamically creating spreadsheet menu items
Publish an add-on privately

How to easily publish add-on to avoid re-authorization request for a copied Spreadsheet?

I have created a Google Sheet that uses some very simple lines of script (made with Tools --> Script editor inside the Sheet). The script only adds simple functionalities, e.g. to click some buttons or extract the Sheet's filename. Now, the workflow in my company is to make a copy of the main Sheet, and work in the copied version. However, when I call the script in the copied version (e.g. by clicking a button) each time an authorization request is shown. I want to avoid this request. Only 1 user needs the funcionality.
I know that this problem can be solved by publishing my script as an add-on (see How to avoid re-authorization request for a copied Google Spreadsheet + script). When publishing the script I am prompted to create a "User-managed Cloud Platform project". Tried this, but I have zero experience with cloud platform projects, OAuth, JavaScript or whatsoever.
Is there any tutorial or simple explanation available for publishing an add-on to solve this (relatively simple) problem? Or should I not even try without any experience?
Help is much appreciated!
To create a Cloud project you just have to go to https://console.developers.google.com -> click create project -> Fill the project info and click in create button [1]. The add-on can help you with your simple problem if you install the add-on for the entire domain so the add-on will be automatically installed in the Spreadsheet App without the need of the authorization request. Here you have some documentation on how to publish your add-on [2][3] and install it for domain-wide [4].
[1] https://cloud.google.com/resource-manager/docs/creating-managing-projects
[2] https://developers.google.com/gsuite/add-ons/how-tos/publishing-editor-addons
[3] https://ctrlq.org/google.apps.script/docs/add-ons/domain-wide.html
[4] https://support.google.com/a/answer/172482

There is no API Console project with the id specified in the manifest's api_console_project_id field

I am trying to publish a spreadsheet web add-on but getting following error.
There is no API Console project with the id specified in the
manifest's api_console_project_id field
Can anyone tell me why I am getting this error ?
Gosh... not sure why this was so hard.
If Google are reading this: it'd be more user-friendly to run the various API checks before the user selects to publish their add-on and/or provide a link to the correct documentation! Then fix that super cryptic error message.
Anyway, if you are stuck with this error, this is what you need to do. (Thanks Tanya Gupta for putting me on the right track).
Step 1: Enable the GSuite Marketplace SDK
Follow these steps:
From the Script Editor, open the Resources menu item then select Cloud Platform Project
Click the button View API Console (you can also click the link with your project ID)
Click the hamburger (navigation) icon on the top left and select "APIs & Services" then "Library"
Search for "GSuite Marketplace SDK". It's important you install the SDK (software development kit) not the API.
Click the ENABLE button
You should now be able to see an option for Configuration in the menu on the left.
Step 2: Configure the GSuite Marketplace SDK
For configuration you will need to:
select at least one language and enter an application description (for your add-on). The name should be pre-filled and match your script name.
upload some icons of various sizes
add a Terms of Service URL (I initially used a public Google Doc for my T&Cs but this would not pass the new OAuth client requirements which require a verified domain. If you don't have a verified domain then users will see a security warning when installing your add-on. You - apparently - can use Github pages but please don't quote me on that.)
enable at least one Add-on extension
When you enable the Add-on extension, you will need to provide the following information:
Add-on Script Project Key can be found from the Script Editor. Go to File > Project Properties and copy the value for Project key (Deprecated)
Add-on Script Version is the version of your script. You can find the version in the Script Editor. Go to File > Manage Versions and select the latest version of your script.
Note: your add-on script version will be updated automatically when you publish new releases of your add-on.
Google documentation:
https://developers.google.com/gsuite/add-ons/how-tos/publish-for-domains#before_you_publish
Just to build on Dagmar's Answer
Solve this issue in 8 steps with Pictures:
On Apps Script Menu Bar, go to Resources > Cloud Platform project...
On Google Cloud Platform, go to the left navigation menu Select APIs & Services > Library
In the search bar that appears, type in "GSuite Marketplace SDK" Hit Search, once it appears click it.
Click on "ENABLE"
Once you click Enable in step 4. the screen below should appear. Select "CONFIGURATION"
Fill the document as you deem fit, but the most important part is shown below.
Scroll Down to Editor Add-on extensions, then select the Google App you're building your add-on for. It's the same process for Docs, Forms Sheets or Slides Add-ons
How to Get Script Project Key. Go back to your Apps Script Page.
Go to File > Project properties. Select the 'Info' tab. Then copy the value of Project key (Deprecated) and paste into the "Script Project Key" field
How to Get Script Version. Still on your Apps Script Page.
Go to File > Manage versions....
Then copy the value of Version and paste into the "Script Version" field
Click Save Changes and voila you're done. Do not forget to add the privacy policy URL and other required info, else the changes will not be saved
If you are publishing on Google Apps Marketplace, you need to not only enable the API, you also need to configure it by entering the needed settings.
1) First click on the enabled API as per image below:
2) Then click on configuration.
3) Then fill out the values as per below:
4) Particularly important are (not shown here):
a) including correct oauth scopes (File->Project Prop->Scope from your script file)
b) Docs Add On Project Key (File->Project Properties->Info->Project key)
c) Docs Add On Script Version (from the developer console)
Now if you go back and publish you should no longer have the error

How can I change my script to AuthMode.LIMITED in my Google Scripts code?

I was trying to publish a new version of an Add-on that was already created, but when I tried to publish it, I can see the menus, sub-menus and I can execute the Add-On Picture 1. The problem is that the other users -who before were able to execute the Add-On- now they don't see the sub-menus and obviously they can't execute the Add-On Picture 2.
I Googled a little bit and I was investigating about this, so I found that there is a method called AuthMode.NONE and AuthMode.LIMITED, I know the differences between them but I don't know how Google Scripts classify the Add-Ons and how to force change the AuthMode to LIMITED, or maybe you can give me another solution that can help.
BTW: I already checked if the Add-On is activated for my document and yes it is, I mean that i have the option: Add-Ons --> Manage Add-Ons --> [my addon] --> Manage --> Use in this document checked.
PD: I tried uninstalling and installing the Add-On, publishing and re-publishing new versions, I tried a lot of things but no solutions.
Thanks in advance!
This read on Authorization modes may help:
If an add-on is installed for a user but not enabled in the current
document, onOpen(e) runs in AuthMode.NONE; if the add-on is enabled in
the current document, onOpen(e) runs in AuthMode.LIMITED. If the
add-on is both installed and enabled, the enabled state takes
precedence, since LIMITED allows access to more Apps Script services.
Note that only published add-ons can be in AuthMode.NONE; scripts that
are bound to a document, including add-ons in development, always run
onOpen(e) in AuthMode.LIMITED. You can, however, test a script as an
add-on to verify that an add-on under development will behave as
intended in either AuthMode.
Check this SO thread for additional reference.

Does Google Apps Script support external IDEs?

I am using Google Apps Script and was wondering if I could use any sort of editor outside of the one Google provides. (I purchased Sublime Text and would like to use that.)
The one Google provides is disgusting, with tiny text even though I have a giant screen and syntax colors that I find a bit difficult to distinguish on a white background with small text, and I don't have the beauties of Sublime like tons of custom keyboard shortcuts, all of my packages, etc.
As of today (May 2018), every scripts that you add on Google App Scripts (including scripts on Google Drive like spreadsheets) will get accessible through https://script.google.com and will have a specific id that you can get through the url by opening it.
By using clasp which handle a project (like git), you can do:
clasp clone {id}
to have your script in a local folder.
Then, after editing your file with your favorite text editor, upload it back with :
clasp push
Google has dropped support for Apps Script inside Eclipse but you can set up a local development environment inside VS Code using the Apps Script Starter kit and CLASP.
Here's a video tutorial to help you get started.
The eclipse plug-in is migrated now. You should install many
files. lastly it couldn't import my google script files.
nod-google-apps-script is depercated.
gdrive can't handle google scripts beyond exporting the project in single json file. issue issue
sublime-editor-plug-in has n't worked for me (I read the whole documents & issues)
The only working solution for me (ubuntu xenial) is clasp.
According to doc it can :
Develop Locally: clasp allows you to develop your Apps Script projects locally. That means you can check-in your code into source control, collaborate with other developers, and use your favorite tools to develop Apps Script.
Manage Deployment Versions: Create, update, and view your multiple deployments of your project.
Structure Code: clasp automatically converts your flat project on script.google.com into folders. For example:
On script.google.com:
tests/slides.gs
tests/sheets.gs
locally:
tests/
slides.js
sheets.js
N.B:. The fature of 'Manage Deployment Versions' isn't supported by eclipse plug in.
It give the following commands:
clasp login [--no-localhost]
clasp logout
clasp create [scriptTitle] [scriptParentId]
clasp clone <scriptId>
clasp pull
clasp push
clasp open
clasp deployments
clasp deploy [version] [description]
clasp redeploy <deploymentId> <version> <description>
clasp version [description]
clasp versions
By using it; you can use your favorite script editor; then push the changes.
Edit
GAS Editor Autocomplete
Thanks to #tehhowch comment.
Auto complete of google objects is almost exclusive for online GAS editor, If you use any external editor , you will only get auto complete for the functions & variables of your own script (I am not sure about eclipse).
But online editor provides autocomplete which reveals the global objects as well as methods and enums that are valid in the script's current context.
To show autocomplete suggestions, select the menu item Edit > Content assist or press Ctrl+Space. Autocomplete suggestions also appear automatically whenever you type a period after a global object, enum, or method call that returns an Apps Script class. For example:
If you click on a blank line in the script editor and activate autocomplete, you will see a list of the global objects.
If you type the full name of a global object or select one from autocomplete, then type . (a period), you will see all methods and enums for that class.
If you type a few characters and activate autocomplete, you will see all valid suggestions that begin with those characters.
You can use node-google-apps-script to edit scripts locally (described in this blog post from the google apps developer blog on 2015-12-17). This way you can use a more comfortable editor, version control and build scripts.
Caveats:
Like the eclipse plugin, node-google-apps-script requires that your add-on is a standalone script.
Debugging still requires google's script editor. With some additional setup you could run functions via the Execution API
It would be awesome if there was a Sublime Text plugin for code completion of google library methods, but I haven't found one (I don't think their default browser editor even offers this, though)
This is an answer for basic/beginner users of Intellij that are looking for code completion when writing Google App Scripts apps. Most of the answers above were helpful for getting me going, especially with Clasp. But none of them actually got Intellij to do the code complete. But this does:
Select File, Settings, Languages & Frameworks, JavaScript, Libraries.
Then on the right select Download, the scroll down to 'google-app-scripts'. (Lots of scrolling) Download and install and you're done. Almost so easy that it really shouldn't have been so hard to find.
Another option to contemplate: using "AppsScript Color" Google Chrome plugin and GAS editor shortcuts.
Here you have a list of most useful shortcuts:
https://opensourceseo.org/useful-tips-for-using-the-google-apps-script-editor/
You can just install a Google Drive command line client (e.g. https://github.com/prasmussen/gdrive) and edit .gs scripts directly.
There's also a way to edit Google Apps Scripts in Eclipse, which may be interesting. https://developers.google.com/eclipse/docs/apps_script