title: Google spreadsheet Script Create Data Validation in certain range
body: <p>I'm trying this script to create data validation but it's always doesn't work </p>
  
  <pre><code>   function test_validation()
        {
        var Spread = SpreadsheetApp.getActiveSpreadsheet();
        var Sheet = Spread.getSheetByName('Sheet1'); 
        var validate1 = Sheet.getRange("A1").getDataValidation();
        Logger.log(validate1.getCriteria());
        Logger.log(validate1.getCriteriaValues());
        var option = new Array();
        option[0]="true";
        option[1]="1";
        option[2]="2";
        option[3]="3";
        var criteria="ITEM_IN_LIST";
        var helpText="Test Help Text"
        var Combobox = Sheet.getRange("A2").getDataValidation();
        //The line below display error 
        //"Cannot find method  (class)setCriteria(string,String[]). "
        Combobox.setCriteria(criteria,option);
        Combobox.setHelpText(helpText);
        var validate2 = Sheet.getRange("A2").setDataValidation(Combobox);
        Logger.log(Sheet.getRange("A2").getDataValidation().getCriteria());
        Logger.log(Sheet.getRange("A2").getDataValidation().getCriteriaValues());
         }
  </code></pre>
  
  <p>Thanks in advance.</p>