0
votes

I have a script project called displayhtmlfromquerystring,

the script file is

function doGet(e){
  var html;
  if(e.parameter.html)
    html=e.parameter.html;

  else
    html="Error no html";

    return HtmlService.createHtmlOutput(html+"<hr/>");
}

I have deployed it as web apps, google gave me two links, one ends with "dev" and one ends with "exec".

When run script with dev link, it is alright but when run with exec link the page displayed the only word "undefined", I got stuck, could any one tell me why?

Link of my script app "https://script.google.com/macros/s/AKfycbyinAHBmjVgKDinY-bCcwQ4bgy87KuibiflG1158qRkBJSSXeMk/exec"

2
Your code is working for me. When you deploy the app make sure you are deploying a new version. Also, you should wrap your if/else statements with curly braces as apps script can be very finicky.Jordan Rhea
It's showing undefined for meCooper

2 Answers

4
votes

The /dev links only work when you are logged in your Google account.

When making any changes to your code, you should go to Publish > Deploy As Web App, select a new version and click Update.

Now the latest changes would be available on the /exec page as well.

0
votes

It's working for me when I use your code:

function doGet(e) { // main function
    var html;
  if(e.parameter.html)
    html=e.parameter.html;

  else
    html="Error no html";
    return HtmlService.createHtmlOutput(html+"<hr/>");
}

enter image description here