0
votes

I am trying to apply conditional formatting rules on a google sheet using a google apps script. I found that this could be done with the API, so I enabled it and have it all working when ran from my script ... but when I trigger the script to run from my sheet, the API batchUpdate doesn't run. I am sure I'm missing something simple ...

The code is in the Themes.gs project of this spreadsheet: https://docs.google.com/spreadsheets/d/1Fs6B-OmlqfoAoon5PcoAYbHq4CO8w0qPqfSRy_OQhe0/copy

specifically this bit doesn't seem to run when the script is triggered from the sheet itself: Sheets.Spreadsheets.batchUpdate(JSON.stringify(functionname), SpreadsheetApp.getActiveSpreadsheet().getId())

1

1 Answers

1
votes

A simple solution is Installable Triggers.

  1. Rename your onEdit() function to something else, like whenWeEdit().
  2. Click the link that says: No triggers set up click here to add one now.
  3. Under Run, select whenWeEdit (or whatever you renamed your function as).
  4. Under Events, select From spreadsheet.
  5. Next, instead of On open, select On edit.
  6. Click save.
  7. Edit the sheet. Your function now seems to work for me. What about you?