Home>
There are methods that you don't know how to use in Google Sheets.
We are currently working on creating data input rules using GAS.
So, I am using 'getAllowInvalid ()' that restricts input other than the specified value in the DataValidation class.
At the stage of applying the created rule, the set value is overwritten with 'true', resulting in a compilation error.
I looked up the reference etc., but I don't know how to use it because I didn't write any specific usage. How should I use it?
The code is as follows: In this case, the integer value is limited to 1 ~ 100.
function myFunc () {
var cell = SpreadsheetApp.getActive (). getRange ("B2");
var rule = SpreadsheetApp.newDataValidation ()
.requireNumberBetween (1,100)
.getAllowInvalid ()
.build ();
cell.setDataValidation (rule);
}
'setAllowInvalid ()' could be used, but this is being validated because the default error dialog cannot be edited.
That's all for the question.
-
Answer # 1
Related articles
- google apps script - i don't know how to conditionally getrange (add or do)
- google apps script - i do not know how to avoid the error of for loop in gas
- google apps script - typeerror: cannot read property '0' of null in google app script
- i want to get the value from each cell of the table with google apps script
- google apps script - i want to make it repeat every few seconds, but is it using setinterval?
- google apps script - i want to write the data stored in an array to a spreadsheet
- google apps script - about the difference between gas function execution and function debugging
- google apps script - i want to insert a decorated text from the gas sidebar into the google docs at the cursor position
- google apps script - i want to automatically generate an sql insert statement from an excel data table with gas
- google apps script - those who can tell us the cause of the phenomenon that only the text of gmail can not be acquired with the
- google apps script - scraping google calendar with gas
- google apps script - i want to display the value of the specified range on the sidebar with gas of the spreadsheet
- google apps script - about gas debug execution
- about google apps script for
- google apps script - i want to display the return value that changed the time with sethours() in the gas cell in time format
- google apps script - add schedule from spreadsheet to calendar
- google apps script - gas schedule duplication prevention
- google apps script - i want to send a message box to the spreadsheet mobile app
- google apps script - the execution icon is grayed out on the gas project screen
- google apps script - i want to determine the "leftmost sheet" in a gas spreadsheet
Trends
I don't know much about myself, so I answer about the subject of the question.
getAllowInvalid () is the information of the obtained validation rule.
It is a thing to check what the setting of "in case of invalid data:" is.
Display a warning if a rule is violatedIf "set": true
Deny input if rule is violatedIf "set": false
Look at this and try to check the operation by actually setting the input rules in the cell.
If there is no input rule setting itself,
TypeError: Cannot call null method "getAllowInvalid"
It becomes.
Take a look at this site as it seems to be helpful for a while.
[GAS] Summary of spreadsheet data input rules [with sample source]
I also don't know because I'm not actually doing it,
Settings related to rule violations
setAllowInvalid (allowInvalidData)
It seems to fit in.
And then "Show validation help text:"
Is setHelpText (helpText) "
It seems to be possible.