0

I try to fire a script when a value in a certain cell or range of cells changes. (it's not changed by the user, so I can't use onEdit)

I've tried to use onChange, but this doesn't fire my script at all

function onChange() {
//  verwijder verwerkte 'klaar' regels

  var actieSheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Actie");
  var asRange = actieSheet.getRange("F3:F25") 
  var asValues = asRange.getValues();
    for (var i = 0; i < 22; i++) {
         x1='false';
         asValues[i][0]= false;
      }
      actieSheet.getRange("F3:F25" ) .setValue (asValues);
}

Is there a way to trigger a script if a Cell changes or even if there is any change in a sheet, it will do for me?

1

onChange isn't a reserved word for a simple trigger on Google Apps Script but there is an "on change" installable trigger that could execute a specified function regardless of it's name. Unfortunately for this case, this installable trigger, the same way that onEdit works, only is triggered by changes made by the user.

If the update is made by a script, make that script run the desired function or "merge" them. If that is not possible, the "workaround" is to use a time driven trigger or the HTML Service and setTimeout to poll the spreadsheet for changes.

The maximum frequency that a time driven trigger could be triggered is every minute (30 minutes for add-ons)

The maximum frecuency for setTimout is every 4ms or every 10ms depending on the web browser.

Be aware that there are quotas and limits that could be or not relevant for your case.

References

Related

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.