miturbe
miturbe

Reputation: 713

range.requireValuesInList and requireValuesInRange seem to be broken

Up to this morning, the following code worked without any problems

function onOpen(e)
{
  var ss = SpreadsheetApp.getActiveSpreadsheet();

  var sheet = ss.getActiveSheet();
  var range = sheet.getRange("B2:B100");
  var dv = range.getDataValidation();
  dv.requireValuesInList(["Shower","Shave","Shop"]);
  dv.setShowDropDown(true);
  range.setDataValidation(dv);    
} 

But this evening, both functions give the error message:

TypeError: Cannot find function requireValuesInList in object DataValidation.
TypeError: Cannot find function requireValuesInRange in object DataValidation.

Any idea what happened? are these functions being replaced?

Just to test, I created a new blank spreadsheet, pasted in the onOpen function and tried to run it... no work.

Any insight is greatly appreaciated.

Upvotes: 0

Views: 338

Answers (2)

John Leary
John Leary

Reputation: 11

If you print the return value of Object.keys(dv) [listing all the methods of the DataValidation object] you now get: isAllowInvalidData,setAllowInvalidData,getCriteriaValues,setHelpText,toString,setCriteria,getCriteria

It seems the DataValidation prototype has just changed utterly, with no warning or documentation of the change. Google’s own documentation (http://developers.google.com/apps-script/reference/spreadsheet/data-validation) refers to the now-defunct DataValidation prototype.

Nice one Google!

Waqar, I’m not sure how you can claim getDataValidation() is undocumented. The DataValidation object returned by getDataValidation() was well-documented at the link I posted above.

Upvotes: 1

Waqar Ahmad
Waqar Ahmad

Reputation: 3732

getDataValidation() method in range object is undocumented so we can't say what happened to this actually. Best practice is to use only those methods and classes which are documented.

Here is a link for the same in issue tracker. You may check it.

https://code.google.com/p/google-apps-script-issues/issues/detail?id=2356

Upvotes: 0

Related Questions