How to debug Google Apps Script (aka where does Logger.log log to?)

前端 未结 12 1829
时光说笑
时光说笑 2020-12-12 11:25

In Google Sheets, you can add some scripting functionality. I\'m adding something for the onEdit event, but I can\'t tell if it\'s working. As far as I can tell

12条回答
  •  隐瞒了意图╮
    2020-12-12 11:52

    Currently you are confined to the container bound nature of using scripts within docs. If you create a new script inside outside of docs then you will be able to export information to a google spreadsheet and use it like a logging tool.

    For example in your first code block

    function setCheckboxes() {
    
        // Add your spreadsheet data
        var errorSheet = SpreadsheetApp.openById('EnterSpreadSheetIDHere').getSheetByName('EnterSheetNameHere');
        var cell = errorSheet.getRange('A1').offset(errorSheet.getLastRow(),0);
    
        // existing code
        var checklist = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("checklist");
        var checklist_data_range = checklist.getDataRange();
        var checklist_num_rows = checklist_data_range.getNumRows();
    
        // existing logger
        Logger.log("checklist num rows: " + checklist_num_rows);
    
       //We can pass the information to the sheet using cell.setValue()
        cell.setValue(new Date() + "Checklist num rows: " + checklist_num_rows);
    

    When I'm working with GAS I have two monitors ( you can use two windows ) set up with one containing the GAS environment and the other containing the SS so I can write information to and log.

提交回复
热议问题