0

I'm trying to build a simple web app using below code. However, when I click the button on html page, log still says no function has been run in this session. I have deployed the latest code, yet no results. I went through several links but I can't figure out what's wrong with the code.

<!DOCTYPE html>
<html>
  <head>
    <base target="_top">
  </head>
  <body>
    <h1> Hello</h1>
    <button id="btn">Calculate</button>

    <script>      

      document.getElementById("btn").addEventListener("click",click_handler);

      function click_handler(){
        google.script.run.userClicked();
      }

     </script>
  </body>
</html>
function doGet() {

  return HtmlService.createHtmlOutputFromFile("page");

}

function userClicked(){
  Logger.log("Someone clicked");
}
5
  • 3
    I think that your script works. But when V8 is enabled, at Web Apps and dialog, it seems that the log is not recorded. So in this case, for example, when your script is modified from Logger.log("Someone clicked"); to return "Someone clicked"; and from google.script.run.userClicked(); to google.script.run.withSuccessHandler(e => alert(e)).userClicked();, when the button is clicked, an alert is opened. By this, you can check Google Apps Script works. When you modified the script, please redeploy Web Apps as new version. If this was not the direction you want, I apologize. Commented Apr 15, 2020 at 5:51
  • Thanks, I see what you are saying. But when I updated the code to pass a parameter to the function userClicked, it seems it is not running as withSuccessHandler doesn't run Commented Apr 15, 2020 at 12:42
  • Thank you for replying. Unfortunately, I cannot understand about your script from when I updated the code to pass a parameter to the function userClicked. This is due to my poor English skill. I deeply apologize for this. In order to correctly understand about your current situation, can you provide it? If you can do, please add it to your question. By this, I would like to check it. If you can cooperate to resolve your issue, I'm glad. Commented Apr 15, 2020 at 22:21
  • I was finally able to solve the issue. One of the element values was undefined which was causing the whole problem.Thanks! Commented Apr 16, 2020 at 5:33
  • Thank you for replying. I'm glad your issue was resolved. I apologize my comment was not useful for resolving your issue. Commented Apr 16, 2020 at 6:15

1 Answer 1

1

The legacy error log window is not working smoothly for V8 run time, But you can view logs under stackdriver logs, you can access the same from script window>View>Stackdriver logging and then from the popup showURL click on 'Apps Script Dashboard.'

You will be able to see each execution that has happened in the script and also the logs under the executions.

Reference:

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.