How to tell scripts editor that I want to attach this script to this spreadsheet using the Id I'm currently editing the spreadsheet in - google-apps-script

If I have a spreadsheet open and use the menu to open the script editor, the script comes up attached to the wrong Google ID. I am in a Chrome browser session that very clearly shows the correct icon in the upper right corner, but the script editor doesn't recognize the owner of the spreadsheet I've called the editor from

Related

Use Google App Script to prevent user opening url link in Sheets if site is already open in another browser tab

I've got a Google Sheet that contains numerous hyperlinks.
I'd like to prevent the user from opening multiple instances of the same site.
ie. user clicks the hyperlink in one cell which opens the linked site in a new tab, then attempts to click the same hyperlink while the first new tab is still open - I'd like a dialogue box to appear saying that they cannot open this second new tab until they have closed the first one.
Is this possible via Google App Script?
Many thanks!
Unfortunately not. GAS has no access to your browser data and cannot know what tabs are open.Moreover, GAS has no way of intercepting hyperlink clicks from within a spreadsheet, it can only do that in a side bar, modal (or modeless) dialog, a custom or an add-on menu or an image with a script attached to it.

Open Chrome tab through Google Apps Script

I'm trying to open a new tab in Chrome via Google Apps Script.
My trigger is From spreadsheet - On form submit
Is it possible?
Thanks
This is not possible. Your trigger is executed on form submit. Someone could submit the form without having the Spreadsheet open. So where would the new Chrome window/tab open?
You can have a sidebar in a Google Sheet that can open a new window/tab but that requires human interaction. Meaning, the user would need to go to the Spreadsheet, click on something to load/open the sidebar, and then click a button that would open a new Chrome window/tab.

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

google app script documentation clear formatting api

I would like to write a google app script to automatically clear the default text formatting of my uploaded/converted google text documents. When editing a google document in google drive, this can be done manually by selecting the text and clicking the the "Format\Clear formatting" drop-down menu item.
I am wondering if there exists such google app api or apis or any other suggestions for doing this programmatically?
Google Apps Script can't run on document upload. So you can't do this without having to install script on every document. And it takes longer than just pressing Ctrl+A and clicking the clear formatting button.

How do you get the url of the script your running in Google scripts?

If your making a script using the Google script editor, how do you get the url of the script your running in the google script editor in google docs? (sorry for not capitalizing the word google)
If I'm understanding your question, you can choose the "Publish" -> "Deploy As a Web App..." menu item. From there, the pop-up will show "Deploy as Web App" with a text box underneath containing the URL. Grab that (or click the "latest code" link just below it). You don't have to follow-through on the re-deploy (if you do, you'll want to use the URL it presents in a pop-up after doing so)
If you haven't previously deployed it, you'll need to save a "version" and deploy it, as touched on here. Upon doing that, it will present you with the Url in a pop-up as mentioned above. If you miss it, the the first part of this answer applies.