Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8338091
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T04:29:17+00:00 2026-06-09T04:29:17+00:00

In Google Sheets, you can add some scripting functionality. I’m adding something for the

  • 0

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, you can’t debug a live event from Google Sheets, so you have to do it from the debugger, which is pointless since the event argument passed to my onEdit() function will always be undefined if I run it from the Script Editor.

So, I was trying to use the Logger.log method to log some data whenever the onEdit function gets called, but this too seems like it only works when run from the Script Editor. When I run it from the Script Editor, I can view the logs by going to View->Logs...

I was hoping I’d be able to see the logs from when the event actually gets executed, but I can’t figure it out.

How do I debug this stuff?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T04:29:20+00:00Added an answer on June 9, 2026 at 4:29 am

    UPDATE:

    As written in this answer,

    • Stackdriver Logging is the preferred method of logging now.

    • Use console.log() to log to Stackdriver.


    Logger.log will either send you an email (eventually) of errors that have happened in your scripts, or, if you are running things from the Script Editor, you can view the log from the last run function by going to View->Logs (still in script editor). Again, that will only show you anything that was logged from the last function you ran from inside Script Editor.

    The script I was trying to get working had to do with spreadsheets – I made a spreadsheet todo-checklist type thing that sorted items by priorities and such.

    The only triggers I installed for that script were the onOpen and onEdit triggers. Debugging the onEdit trigger was the hardest one to figure out, because I kept thinking that if I set a breakpoint in my onEdit function, opened the spreadsheet, edited a cell, that my breakpoint would be triggered. This is not the case.

    To simulate having edited a cell, I did end up having to do something in the actual spreadsheet though. All I did was make sure the cell that I wanted it to treat as “edited” was selected, then in Script Editor, I would go to Run->onEdit. Then my breakpoint would be hit.

    However, I did have to stop using the event argument that gets passed into the onEdit function – you can’t simulate that by doing Run->onEdit. Any info I needed from the spreadsheet, like which cell was selected, etc, I had to figure out manually.

    Anyways, long answer, but I figured it out eventually.


    EDIT:

    If you want to see the todo checklist I made, you can check it out here

    (yes, I know anybody can edit it – that’s the point of sharing it!)

    I was hoping it’d let you see the script as well. Since you can’t see it there, here it is:

    function onOpen() {
      setCheckboxes();
    };
    
    function setCheckboxes() {
      var checklist = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("checklist");
      var checklist_data_range = checklist.getDataRange();
      var checklist_num_rows = checklist_data_range.getNumRows();
      Logger.log("checklist num rows: " + checklist_num_rows);
    
      var coredata = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("core_data");
      var coredata_data_range = coredata.getDataRange();
    
      for(var i = 0 ; i < checklist_num_rows-1; i++) {
        var split = checklist_data_range.getCell(i+2, 3).getValue().split(" || ");
        var item_id = split[split.length - 1];
        if(item_id != "") {
          item_id = parseInt(item_id);
          Logger.log("setting value at ("+(i+2)+",2) to " + coredata_data_range.getCell(item_id+1, 3).getValue());
          checklist_data_range.getCell(i+2,2).setValue(coredata_data_range.getCell(item_id+1, 3).getValue());
        }
      }
    }
    
    function onEdit() {
      Logger.log("TESTING TESTING ON EDIT");
      var active_sheet = SpreadsheetApp.getActiveSheet();
      if(active_sheet.getName() == "checklist") {
        var active_range = SpreadsheetApp.getActiveSheet().getActiveRange();
        Logger.log("active_range: " + active_range);
        Logger.log("active range col: " + active_range.getColumn() + "active range row: " + active_range.getRow());
        Logger.log("active_range.value: " + active_range.getCell(1, 1).getValue());
        Logger.log("active_range. colidx: " + active_range.getColumnIndex());
        if(active_range.getCell(1,1).getValue() == "?" || active_range.getCell(1,1).getValue() == "?") {
          Logger.log("made it!");
          var next_cell = active_sheet.getRange(active_range.getRow(), active_range.getColumn()+1, 1, 1).getCell(1,1);
          var val = next_cell.getValue();
          Logger.log("val: " + val);
          var splits = val.split(" || ");
          var item_id = splits[splits.length-1];
          Logger.log("item_id: " + item_id);
    
          var core_data = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("core_data");
          var sheet_data_range = core_data.getDataRange();
          var num_rows = sheet_data_range.getNumRows();
          var sheet_values = sheet_data_range.getValues();
          Logger.log("num_rows: " + num_rows);
    
          for(var i = 0; i < num_rows; i++) {
            Logger.log("sheet_values[" + (i) + "][" + (8) + "] = " + sheet_values[i][8]);
            if(sheet_values[i][8] == item_id) {
              Logger.log("found it! tyring to set it...");
              sheet_data_range.getCell(i+1, 2+1).setValue(active_range.getCell(1,1).getValue());
            }
          }
    
        }
      }
    
      setCheckboxes();
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im working on some google doc spread sheets and I thought im not sure
Can you produce a Python example of how to download a Google Sheets spreadsheet
I was searching google for something and saw the post that some one needed
Is it possible to nest simple programs within a Google Sheets, similar to how
I have a user that created about 50 sheets inside a Google Spreadsheet. Each
Google calendar throws at me rfc3339, but all my dates are in those milliseconds
Google Maps itself can sort of Highlight areas, when you are searching for example
In Google Sheets I'm looking for an array formula to provide the first day
In Google Docs Spreadsheets, one can use Range Names to put labels on ranges
This is probably quite simple but I've googled and can't find an answer. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.