Skip to content

Instantly share code, notes, and snippets.

@hlecuanda
Created August 19, 2015 08:32
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save hlecuanda/326aa8c5d61260551336 to your computer and use it in GitHub Desktop.
Save hlecuanda/326aa8c5d61260551336 to your computer and use it in GitHub Desktop.
A pattern to debug google apps script (GAS) triggered functions.
/**
* Test function for onEdit. Passes an event object to simulate an edit to
* a cell in a spreadsheet.
*
* Check for updates: http://stackoverflow.com/a/16089067/1677912
*
* See https://developers.google.com/apps-script/guides/triggers/events#google_sheets_events
*
* on Script editor, set to debug THIS function, but create breakpoints
* on the onEdit Function
*/
function test_onEdit() {
onEdit({
user : Session.getActiveUser().getEmail(),
source : SpreadsheetApp.getActiveSpreadsheet(),
range : SpreadsheetApp.getActiveSpreadsheet().getActiveCell(),
value : SpreadsheetApp.getActiveSpreadsheet().getActiveCell().getValue(),
authMode : "LIMITED"
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment