问题
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.
}
回答1:
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.
来源:https://stackoverflow.com/questions/28733976/how-do-i-find-the-operations-location-within-the-code-this-operation-is-not