Clay Smith
Clay Smith

Reputation: 43

google.script.run throwing Transport error

I've recently been experiencing an error using google.script.run while building an AddOn

The Chrome Developer console is displaying: "message: "There was an error during the transport or process…this request. Error code = 10, Path = /wardeninit", name: "TransportError", stack: "TransportError: There was an error during the tran…/js/3535021228-warden_bin_i18n_warden.js:198:247)"

And I see: Uncaught TypeError: a is not a function at hf....

It appears this is on Google's side. Who can I contact to get it looked at? Any other thoughts on why this may be occurring?

Here's code which is creating this error. Sample Code: https://docs.google.com/spreadsheets/d/1hWifp75srJFHpnkCQx3YLxa3XB2gsKSmHNz3muYXK8U/edit#gid=0

function onInstall(e){
  onOpen(e);
}

function onOpen(e){
  var ui = SpreadsheetApp.getUi();
  ui.createAddonMenu()
  .addItem('Launch main menu', 'showSidebar').addToUi()
}

function showSidebar() {
  var html = HtmlService.createTemplateFromFile('mainSidebar').evaluate()
      .setTitle("Test")
      .setWidth(300);
  SpreadsheetApp.getUi() 
      .showSidebar(html);
}


function unittest(){
   var documentProperties = PropertiesService.getDocumentProperties();
   documentProperties.setProperty('firstRun', true);
}

function checkProperty(prop){
  let documentProperties = PropertiesService.getDocumentProperties();
  let property= documentProperties.getProperty(prop)
  return property
}
<!DOCTYPE html>
<html>
  <head>
    <base target="_top">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css">
    <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
    <script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
    <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.min.js"></script>
    <style>
      body { font-size: 16px;}
      .button1 {
        background-color: #2A8947; /* green */
        border: none;
        color: white;
        padding: 15px 24px;
        width:300px;
        text-align: center;
        text-decoration: none;
        display: inline-block;
        font-size: 14px;
      }
    </style>
  </head>

  <body>
 <div style="margin-bottom:12px" > 
  <h1>Main Menu</h1>

  <ul class="collapsible">
    <li>
      <div class="collapsible-header button1">Menu</div>
      <div class="collapsible-body"><span>Accordian</span></div>
      <div class="collapsible-body"><button class="btn waves-effect waves-light green darken-2 white-text" id="setup" align="center">Setup<i class="material-icons right">settings</i></button></div>
    </li>
  </ul>
 </div>

<hr>  


<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>

<script>
$(document).ready(function(){
    $('.collapsible').collapsible();
    google.script.run.withSuccessHandler('testRun').withFailureHandler('fail').checkProperty('firstRun')

});

function testRun(run){
   console.log('run',run)
 
}

function fail(e){
  console.log('fail',e)
}

</script>

  </body>
</html>

Upvotes: 2

Views: 2219

Answers (1)

Diego
Diego

Reputation: 9571

withFailureHandler() and withSuccessHandler() expect functions as arguments, not strings.

google.script.run.withSuccessHandler(testRun).withFailureHandler(fail).checkProperty('firstRun')

Upvotes: 3

Related Questions