[Solved] I want to create a dropdown list with the data available on another sheet


You can’t use getNamedRanges that way. You get all of the named ranges and then iterate over them. Then you can assign the rule.

function dropOrderStatus() {
  var cell = SpreadsheetApp.getActive().getRange('B12');
  var orderStatusRange = SpreadsheetApp.openById("1sO_M9H7CrCevNrKCr0eimxb9lmY458NeyNHTf8RpS60").getNamedRanges();

  var namedRanges = [];
  for(var i = 0; i < orderStatusRange.length; i++) {
    namedRanges.push(orderStatusRange[i].getRange());
  }

  //I have no idea what your named ranges look like so you will need to modify this.
  //It only takes the first named ranged in the array of named ranges
  //If you want a dropdown for this you need to set it up differently
  var rule = SpreadsheetApp.newDataValidation().requireValueInRange(namedRanges[0]).build();

  cell.setDataValidation(rule);
}

As a sidenote, I published a free add-on in the web store that builds these kind of dropdowns, and I would love feedback. I don’t know what the rules are about linking to things like that, but you can find it easily by searching ‘Multi Dropdowns’

1

solved I want to create a dropdown list with the data available on another sheet