I am trying to run the following code line of code (taken from https://developers.google.com/apps-script/reference/spreadsheet/range#copyTo(Range,Object)):
sheet.getRange("D1:D").copyTo(sheet.getRange("D1"), {contentsOnly:true});
I am getting the error "We're sorry, a server error occurred. Please wait a bit and try again."
It runs without a problem if I run the code without the contentsOnly bit:
sheet.getRange("D1:D").copyTo(sheet.getRange("D1"));
I am attempting to copy > paste values as I want to remove the formula that is in the cells.
I thought it could be that I had a Spreadsheet and not a Sheet (I was using openById, whereas the example uses getActiveSheet), but when I added getSheetbyName() to get a sheet instead, I still got the same error.