Carlos
Carlos

Reputation: 1

Is it possible to run a google script with the web app URL on the New Google Sites?

I was playing around with a macro-nutrient calculator that I wanted to make. I was trying to create a cleanup function for the spreadsheet which would be accessed by clicking a link to a script from the site. Here is what I have so far:

function doGet(){
  function ClearMacros(){
    var spreadsheet = SpreadsheetApp.openById('SPREADSHEETID');
    var sheet = spreadsheet.getSheetByName('Fat Entries');
    sheet.getRange('A2:B1001').clearContent();
    var sheet = spreadsheet.getSheetByName('Protein Entries');
    sheet.getRange('A2:B1001').clearContent();
    var sheet = spreadsheet.getSheetByName('Carb Entries');
    sheet.getRange('A2:B1001').clearContent();
  }
}

Results: Error: The script completed but did not return anything.

When I run it from the script IDE it works, so I am not sure why it isn't working when I click the link to the web app.

Upvotes: 0

Views: 279

Answers (1)

abielita
abielita

Reputation: 13469

Based from this documentation, a script can be published as a web app if it meets these requirements:

  • It contains a doGet(e) or doPost(e) function.
  • The function returns an HTML service HtmlOutput object or a Content service TextOutput object.

As referred in this thread, try to create a new version of My Project because maybe updating the previous version did not update its sharing settings.

Upvotes: 1

Related Questions