0

I'm creating a Google addon for docs. So I'm using html, scriptlets and java. Everything has run fine, but suddenly, I'm getting this error and I don't know how to solve it.

When I run the html, the error comes up, as shown in the table. Within Developer Tools, the following errors are shown: 1. Google Apps Script: This operation is not supported from a callback function. 2. The given range does not belong to the current selection's document. 3. G.Y0

How do I take this information to find the location of the error?

ADDITIONAL INFORMATION per request........

Sorry, I'm using javascript.

My html file has only two server side function calls. The first is via a scriptlet, which loads prior to loading the html. This call function returns an array used to create a sidebar with dynamic html for a table.

<? var rubric = getRubric(); ?>

The second, a button, is in the sidebar. The button stores radio button ids located in the sidebar and then sends them over to the server-side function. I placed a withFailureHandler on it.

<td class="tableCalcButton"><input type="button"  class="button" value="Fill Rubric" onclick= "fillRubricA()"  /></td>
<script>
  function fillRubricA(){                              
            var selection = [];
            var matrix = document.getElementsByName('rbRubric').length;  // this = 20  a 4x5 matrix.
            selection[0] = [  [document.getElementById('rbRubric11').value], [ matrix / (document.getElementById('rbRubric11').value - 1) + 1 ] ];
            for ( var r = 1; r < selection[0][0]; r++) {
                   for ( var c = 1; c < selection[0][1]  ; c++) {
                          if (document.getElementById( 'rbRubric' + r + c).checked == true) { selection[r] = [c];}
                       }
                }
            google.script.run.withFailureHandler(onFailure)
                  .fillRubric(selection);

            console.log('[0][0] ' +selection[0][0]);
          }
   function onFailure(error){ alert(error.message + '  Server is not found. Try your selection again.'); }

</script>

The server side functions look like this...

 function getRubric() {
// there is code here that I know works fine.  Then I make a function call.
// Locate Rubric Table
var rubricTable = findRubricTable();
if (rubricTable == null ){
    var alert = ui.alert('Server not found.  Try your selection again.');
    return;
  }
// there is more code that works.
// loadRubric is the array I send back to scriptlet that called it.
return loadRubric;
}

This server function is called from within the getRubric().

function findGradeTable(){
  //the code here does not call another function and works fine.  
  //It finds the correct table id number and returns it.
return rubricTable; 
}

Lastly, the radio button calls this function which does not call other functions and makes the final format changes on the document.

function fillRubric(selection){
//This javascript works fine.
}
M Buck
  • 49
  • 10
  • Are you using Java or Javascript? They are not even close to the same thing. Your text says "Java", your tag says "Javascript". Also, you will likely have to show the relevant code for people to be able to help. – jfriend00 Feb 26 '15 at 04:09
  • jfriend00, I'm using javascript. I've added more details as you have suggested. Overall, I know the code works well. However, I'm still working to understand and implement successful callbacks. If you can see where the issue resides, I'd appreciate it. Or, if you can guide me how to use google dev tools to pin point where the callback error occurs, that would be great. – M Buck Feb 26 '15 at 15:33

1 Answers1

0

Look at the "Execution Transcript" under "View" in the Script Editor, immediately after receiving the error.

It should show the file & line number where the exception occurred.

Cameron Roberts
  • 7,127
  • 1
  • 20
  • 32