I am trying to use the Google Sheet's Script Editor to write a script for a Dependent List using the following script:
function setDataValid_(range, sourceRange) {
var rule =
SpreadsheetApp.newDataValidation().requireValueInRange(sourceRange,
true).build();
range.setDataValidation(rule);
}
function onEdit(){
var pageCell = SpreadsheetApp.getActiveSheet().getActiveCell();
var pageColumn = pageCell.getColumn();
if (pageColumn == 6 && SpreadsheetApp.getActiveSheet().getName() ==
'raw_data'){
var range = SpreadsheetApp.getActiveSheet().getRange(pageCell.getRow(),
pageColumn + 2);
var sourceRange =
SpreadsheetApp.getActiveSpreadsheet().getRangeByName(pageCell.getValue());
setDataValid_(range, sourceRange);
}
}
There are two different tabs I am using in this spreadsheet, "raw_data" and "Range". I had created a drop down list in column F of "raw_data" that lists values from a specified range in "range". Each of these values is also the title of a named range in that tab. The script above is suppose to read the value selected in column F and then two columns over, in column H, create another drop down list based on the values associated with that named range.
The problem I keep having is every time I click run I get the error message "Could not connect to server. Please save and try again" or if I try to set up a project trigger I get "We're sorry, a sever error occured. Please wait a bit and try again".
I have created new spread sheets, recreated the named ranges, created new script files and tried running the script from a separate computer but error message continues.
I haven't been able to find a solution to this and even when I try to use the dubug tool it gives me an error message. Does anyone know what the issue is or how I might resolve this?