This one should be an easy yes or no. Is it possible to paste data validation only with Google Apps Script?
What I want to do is have the code copy the data validation from the row above the active cell, then paste the data validation into the row of the active cell.
I tried copyTo:
function updateFormat() {
var rowNumber = SpreadsheetApp.getActiveSpreadsheet().getActiveSelection().getRow();
var rowAbove = rowNumber -1 ;
var targetRange = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet().getRange(rowNumber, 1, 1, 36);
var templateRange = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet().getRange(rowAbove, 1, 1, 36);
templateRange.copyTo(targetRange);
}
but–obviously–that copied the data validation and the contents of the row above, which is not the goal.
Any ideas?
Thanks in advance!
Adding the optArgument {formatOnly:true} works (See Ref). So
becomes
I’ve refactored your code slightly and tested using: