disable dismiss hyperlink and message on google spreadsheet - google-apps-script

When we run any method of Google App Script,a message appears on Google Spreadsheet with dismiss hyperlink.
For Example:
Running Script methodname Dismiss hyperlink
I would like to know if there is any option to disable the message and dismiss hyperlink that appears on Google Spreadsheet when any function is executed at the back ground. In not , please share what alternates are available to hide this out.

It is within a div of class docs-butterbar-container so on your own machine, you could add
.docs-butterbar-container {
display:none;
}
to a user stylesheet.
But if you are hoping to hide it from other others of your sheets/scripts then your likely out of luck, unless you have means of rolling out user stylesheets.
I also wouldn't recommend hiding this. It's useful.

Related

Clear certain cells on Window Close AppScript

I wanted an appscript mechanism, where I want to clear certain cells (A2:B8) if the spreadsheet window is closed. I have one way of doing it and that is:
onOpen()
{
sheet.getRange("A2:B8").setValues("");
}
But this seems like a hack but I wanted to know if there's a definite way to do so... like for example:
Browser.onWindowClose()=>{clearCells()}
You maybe able to do this if you have a modal dialog or sidebar open. If sidebar or dialog close is attempted, you may be able to catch the event with beforeunload, if catched, clear all cells using google.script.run(). This assumes user is closing the sidebar before/along with the Google sheets main web app.
There isn't onClose() or onExit() built in trigger as of yet.
Here is the list with all the currently available triggers.
The lack of this feature has already been reported in the IssueTracker.
You can go there and click on the star button to the top left of the page to "increase" the chances for this feature to be implemented by google.
As a side note, clearContent() would be more appropriate:
sheet.getRange("A2:B8").clearContent();

Activating script via button press on embedded Google Sheet

I am trying to embed a Google Spreadsheet that has a script I'd like users to be able to activate. I don't want them to be able to edit anything on the page.
I thought I could do this by
Share sheet and set to edit permissions
Restrict editing on the one sheet I want to share (the images sit above the cells, so I thought this would prevent people from editing cells but allow them to click on the button
Publish to the web
Embed the sheet
Here is the iframe I used:
<iframe width="1250" height=1000 src="https://docs.google.com/spreadsheets/d/e/2PACX-1vRRajy1TK9Y9YQg-Df3bwTy9ktxPECq6T5gS7UfkrYpV_osxwDwRuQClC168B8-o4KsCdFl4kfMYtau/pubhtml?gid=1796260078&single=true&widget=true&headers=false"></iframe>
For context the scripts hide or show different rows. Clicking "show game 2" hides a section of rows and "show game 1" unhides these rows.
The sheet embeds okay but isn't interactable. I have turned off the restricted editing to test (it's back on) and that didn't allow people to edit anything, so I am not sure what I am doing wrong here.
Any help would be greatly appreciated! Cheers!
Workaround:
Use a another button outside the embedded spreadsheet instead.
Publish a headless web-app from your sheet using doPost()
On Button click, use JavaScript to post from your website to apps script web-app
On receiving post request, hide/show the rows using your original script.
References:
Web-app

How to reset/reload/restart a Google Form

I would like to display a feedback google form in kiosk mode on a tablet. After form completion, it should show a "thank you" message and restart the form for the next visitor.
I noticed a "Show link to submit another response" in the form settings menu, but no way to accomplish a auto refresh.
Fortunately there is the google's script manager. As the script runs in a sandboxed iframe, I cant even access the window object. I know that I can access the FormApp.getActiveForm() method, but there seem to be no way to reset/reload the form.
I can't think of another way doing it.

How to apply a Google Apps script to a gmail message from gmail screen

If I have a Google Apps Script that does some processing to a single gmail message, how can I trigger it from the gmail web interface so it gets applied to the message I have currently open on screen?
The closest way I've found is to apply a label and have a background process monitoring labels. Is there a way to add a button or menu option to gmail instead?
Thanks
No, there isn't. At least not using any "native" Apps Script or Gmail feature. You'd have to write a browser extension to achieve this.
Another thing you could do (aside from the special label) is to gmail's URL (while viewing the message) and paste it in your Apps Script interface (previously opened in another tab). Then your script can extract the message id from the URL and work on it right away.
Also, you could do something clever like having your script receive the id (or full gmail url) from a parameter on the script's own url, e.g. https://script.google.com/macros/s/<your-script-key>/exec?gmail=<url>
Then set up your browser (I know Chrome and Firefox do this) to trigger your script and pass the parameter based on a keyword in the location bar. I use mostly just one letter (like "y script" searches the word "script" on youtube. If you use for example "a", you could hit ctrl+L (select location bar), ctrl+c (copies gmail url), ctrl+t (new tab), then type "a ", ctrl+v, enter. Not exactly clicking a button on the gmail's interface, but does the job rather easily. If you're inclined to keyboard shortcuts like I am, this is even a preferable way :)
Another options is to label your message with some label and have an app script scan for this label every X minutes and process all messages it finds.

Creating a notification from within a notification

I'm creating an extension for Chrome, and one of the functionalities included is the ability for the end user to add people as contacts.
Currently, the contact is saved to the database via AJAX, after which a desktop notification is displayed telling the user that the deed has been done.
However, I would want to first ask the user if he's sure he wants to do that. So I got the mad idea of wanting to create a new notification from within a notification.
So first, the confirmation HTML notification would be created from the background.html, and displayed. It contains a button, and upon clicking it, it should run the AJAX function and create a second notification, containing the feedback.
However, I seem to be unable to do this. I can't run createNotification() from the notification, sendRequest() doesn't seem to go through neither, and I can't use the onClose listener from background.html, because I want to differentiate between clicking the "Yes" button and the "No" button.
Is there any way I can do this? And if not, how should the confirmation dialog be implemented instead?
Have you tried using chrome.extension.getBackgroundPage()? This may provide the access to your background page's API that you require. For example, your first notification page calls the following when Yes is clicked;
function yesClicked() {
chrome.extension.getBackgroundPage().showSecondNotification();
}
The background page declares the showSecondNotification method as follows;
function showSecondNotification() {
webkitNotifications.createHTMLNotification(
chrome.extension.getURL('notification2.html')
).show();
}
Hopefully, this will cause the second notification to be displayed. I've used a similar method in my extensions before but only to retrieve information from the background page. However, I see no reason this shouldn't work.