javascript - Google Scripts external spreadsheet data validation -


i interested in automating data validation of google spreadsheet against google spreadsheet using google scripts. can't seem find way reference range of spreadsheet using openbyid method. thoughts?

function externalsheetdatavalidation() {      var cell = spreadsheetapp.getactiverange();      //var datavalidationsheet = spreadsheetapp.getactivespreadsheet().getsheetbyname("datavalidationrules");      //var datavalidationsheet = spreadsheetapp.openbyurl("https://docs.google.com/spreadsheets/d/10z2s1bsrihzzbbrmfpmhephnpx-kjdv3lllbv0l59g8/edit#gid=0");      var datavalidationsheet = spreadsheetapp.openbyid("10z2s1bsrihzzbbrmfpmhephnpx-kjdv3lllbv0l59g8");      var sheet = datavalidationsheet.getsheets()[0];      var range = spreadsheetapp.getactivesheet().getrange("a3:a4");      var rule = spreadsheetapp.newdatavalidation()          .requirevalueinrange(range, true)          .setallowinvalid(false)          .build();      cell.setdatavalidation(rule);        logger.log(datavalidationsheet.getname());  }

if understanding correctly, issue having selecting data range external spreadsheet? im assuming datavalidationsheet supposed external sheet. looks on right track. looks issue expecting sheet active once grab it. try change: var range = sheet.getrange("a3:a4");
grabbing external sheet, getting range sheet active. helps!


Comments

Popular posts from this blog

c# - Better 64-bit byte array hash -

webrtc - Which ICE candidate am I using and why? -

php - Zend Framework / Skeleton-Application / Composer install issue -