copyTo Error: Exception: The parameters (SpreadsheetApp.Range,number,(class)) don't match the method signature for SpreadsheetApp.Range.copyTo
01:36 20 Oct 2025

I have a spreadsheet from last year and it worked OK then. Without edits, I opened it and now it throws this execution error:

Exception: The parameters (SpreadsheetApp.Range,number,(class)) don't match the method signature for SpreadsheetApp.Range.copyTo.

This line with error it points to is:

validationSource.copyTo(validationDestination, SpreadsheetApp.CopyPasteType.PASTE_DATA_VALIDATION, false);

I can confirm that both validationSource and validationDestination are variables of class Range from .getRange().

What I don't understand:

  1. Why it worked before and now it doesn't without the code getting edited.
  2. Why the exception says: (SpreadsheetApp.Range,number,(class)). false is not a class, false is a boolean value.

I even tried to coerce a boolean value, just in case, with:

validationSource.copyTo(validationDestination, SpreadsheetApp.CopyPasteType.PASTE_DATA_VALIDATION, 1==0);

and still the same error.

Now I'm wondering if this is a Google Apps Script bug.

References:

Example code:

function onEdit(e) {

  for (let c=1; c <= e.range.getNumColumns(); c++) {
    for (let r=1; r <= e.range.getNumRows(); r++) {
      let cell = e.range.getCell(r, c);
      let validationSource = e.source.getSheetByName("Lists").getRange("A1");
      let validationDestination = e.source.getSheetByName("Ratings").getRange(cell.getRow(), cell.getColumn()+3);

      if ( cell.getValue() ) {
        validationSource.copyTo(validationDestination, SpreadsheetApp.CopyPasteType.PASTE_DATA_VALIDATION, false);
      } else {
        validationDestination.setDataValidation(null).clearContent();
      }
    }
  }
};
google-sheets google-apps-script triggers