简体   繁体   中英

Script in Google site fail

Just need a little help to start...

I'm trying to run this Google sample script in a Google site and it doesn't works.

I did follow the procedure proposed in this tutorial... https://developers.google.com/apps-script/articles/getting-started-with-sites

function doGet(e) {
    var app = UiApp.createApplication();
    // hello world label
    var helloworldLabel = app.createLabel("I love Apps Script!").setStyleAttribute("fontSize","16px");
    // add the label to the app container
    app.add(helloworldLabel);
    return app;
}

The error message in French ;;; : GOOGLE DRIVE Désolé, la page (ou le document) que vous souhaitez afficher n'existe pas. Vérifiez l'adresse, puis réessayez.
"GOOGLE DRIVE Sorry, the page(document) doensn't exists"...

I do probably miss something very basic...

When I run this other code directly in the script editor, it works fine...

function sendEmail()
{ 
    MailApp.sendEmail('jp.bihin@skynet.be', 'Salut !', 'Ce message est envoyé par des scripts Google Apps. Chouette non ?'); 
} 

Thanks for your help.

There has been some changes in the way webapps have to be published (quite) recently : see docs : " In order to embed a script in Google Sites as a Google Apps Script Gadget, you must first deploy the script as a web app"

It seems that old scripts can run directly as they are inserted in the page but new ones have to be published prior to their insertion as gadgets. Documentation is not very clear but a few tests seems to confirm that this step is necessary (create version / publish as webapp).
It makes sense when you consider the permissions and the identity considerations when running a webapp as an embedded gadget.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM