How to get current sheet in app script?

All I need is to execute a piece of code on the row that has just been added, I'm trying to get the active workbook by using the following code but the result is null. How do I refer in a script to newly added row? 


var workbook = SpreadsheetApp.getActiveSpreadsheet();

 

Solved Solved
0 3 667
1 ACCEPTED SOLUTION

If it's a stand-alone script, there is never an active sheet, you have to use SpreadsheetApp.openById()

View solution in original post

3 REPLIES 3

Are you using onChange, or calling a script from a Bot-Task, or something else?

Hi Marc - it's a bot - it triggers on a newly added row and calls a stand-alone app script.

If it's a stand-alone script, there is never an active sheet, you have to use SpreadsheetApp.openById()

Top Labels in this Space