1

I want to embed Google Drive Scripts/ project from Google Sites but I can not.

Google Sites alert me with a message

This url is not recognised as a valid Apps Script

after I

  • created project-script from Google Drive,
  • added a function function doget(e) { code; code; code; ... },
  • published the script ("Deploy as web app"),
  • retrieved the link link (e.g: https://script.google.com…1DkWAQ/exec), and
  • in the Google Sites page,
    • I edited page and inserted a script from menu: Insert > Apps Script Gadget.

In the next page I enter script's link but a message box shows up: "This url is not recognised as a valid Apps Script"

Where I am wrong?

My question is: Can I execute Google Drive Script without adding code in site's page? Is it possible to execute from several Google Sites' pages a Google Drive Script with different parameters?

Thanks,

Michele

Mr Fooz
  • 109,094
  • 6
  • 73
  • 101
user1565446
  • 11
  • 1
  • 2

3 Answers3

2

The url is different when embedded in a Google site, here is an example that can be inserted :

`https://sites.google.com/macros/exec?service=keyxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx`

You can pick the key in the standalone url. I must admit that the interface is not really clear about that, nor is the documentation

EDIT : since some people seems to be sceptic ;-) here is an example with a shared script written as a script file :

the url given for a standalone app is :

https://script.google.com/macros/s/AKfycbxlPTVLSLfO3d1w2vSrMzzh57p9DJM6ivCIHiIfTB2AKqubSs1L/exec

The same script in the site page is :

https://sites.google.com/macros/exec?service=AKfycbxlPTVLSLfO3d1w2vSrMzzh57p9DJM6ivCIHiIfTB2AKqubSs1L

feel free to check ;-)

in the gadget properties it shows up like this :

enter image description here

Serge insas
  • 45,904
  • 7
  • 105
  • 131
  • Hi Serge, you're great, in addiction to your answer, i added in the google site link page, the string "&from_page=X": https://sites.google.com/macros/exec?service=AKfycbw....OE9jg&from_page=X so, in function doGet(e) in the "e.parameter.from_page" i can read the parameter "X" bye ;) (i'm sorry for my bad english) – user1565446 Jul 31 '12 at 22:16
1

I believe this summarizes the correct format for URLs of scripts saved on Drive for inserting with a Script Gadget on Google Sites:

Note the domain part is 'sites.google.com' not 'script.google.com'

Andrew M.
  • 283
  • 2
  • 9
-1

As my experiences, you can't create an Apps script in Google Drive and then embed it in Sites.

To do that, log into your site's dashboard. You can do that by selecting menu item More > Manage site from your site (with logged in account). Then select tab Apps Scripts, hit the button Add new script. From there you can code your script. When you're done, come back to your site, edit a page and insert that script into your page.

Anh3Saigon
  • 199
  • 5
  • please try to avoid giving wrong answers without checking others answers. If you are experiencing some difficulties with url modification feel free to ask for more info. – Serge insas Jul 31 '12 at 12:58
  • I *did* that on my site. As I told it's my experience. That means I tried with my own cases. At least I want to help him with my knowledge. How can I know that is wrong??? Do you ever want to show me what is wrong? It's shame on you. – Anh3Saigon Jul 31 '12 at 13:00
  • I added an explicit example of a script written in a script file that is embedded in a site with a slightly modified url, I didn't invent this stuff, It is related to a [known issue (1415)](http://code.google.com/p/google-apps-script-issues/issues/detail?id=1415) and this solution was given by a Googler. Sorry if I offended you, I just suggested to try the solution that was in my answer before saying it can't be done. – Serge insas Jul 31 '12 at 13:29
  • Thanks. Sorry for my words too. – Anh3Saigon Jul 31 '12 at 13:34