Как записать var в google.script.run - PullRequest
0 голосов
/ 22 апреля 2020

У меня вопрос с этим кодом:

<td><input type="button" value="Valider" name="submit" id="submitButton" onclick="foo()"/></td></div>
function foo(){
       vrailastRow = 0;
       google.script.run.withSuccessHandler(function(lastRow){  
           vrailastRow=lastRow-1;
           console.log(vrailastRow); // => Display value 8
       }).withFailureHandler(function(error){
           console.log('error');
       }).lastR();

       console.log(vrailastRow); // => Display value 0 (value define at start)
}

Первый console.log печатает значение 8, а второй console.log печатает 0. Я не прибыл, чтобы использовать vrailastRow из google.script.run

Есть идеи?

Функция .gs:

    function lastR() {
    var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
    var lastRow = sheet.getLastRow();
    return lastRow;
    }
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...