Uncaught TypeError: google.script.run. is not a function

Viewed 3876

I have a code associated with a Google Spreadsheet, accessible via the script editor. In the code, I have a .gs file as the main body and I have an HTML file which is a sidebar used in the spreadsheet. I'm trying to call a function in the sheet.gs file from the HTML editor, would I do this using "google.script.run.myFunction()" in the HTML File, am I doing this wrong?

Basically in my sheet.gs I have

function myFunction() {
    // do a thing
}

and in my HTML file I'm trying to call myFunction() like google.script.run.myFunction().

Please help me figure this out, thank you! Edit: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

I have this function that is called by a button click

    <div class="btn" onclick="generateSpreadsheetReport()">View Responses</div>

and the function is

        function generateSpreadsheetReport() {
        console.log("RUN!");
        console.log("StudentAverage1");
        var day = document.getElementById("day");
        if (!day.value) day.value = "";
        var course = document.getElementById("courses");
        var stud = document.getElementById("stud");
        console.log(day.value,course.value,stud.value)
        google.script.run.withSuccessHandler(displayAverage).sortByParameter(day.value||"", course.value||"", stud.value||"");
        console.log("StudentAverage2");
      google.script.run.getStudentAverage(); // <----- This line right here isn't working.
    }

And then in my sheet.gs I have a function called getStudentAverage() which is defined and it shows up in the library when I click on it from the resources page. So I Assume I am calling it wrong in my HTML

2 Answers
Related