Fixed
Status Update
Comments
is...@gmail.com <is...@gmail.com> #2
I'd also love to see this as a formula, in order to apply conditional formatting based on the whether the content of a cell passes the data validation rule or not. Something like ISVALID(value).
os...@gmail.com <os...@gmail.com> #3
I'm completely baffled: what's the point of "Data Validation" if there's no way of checking whether the data satisfies the condition? Could we all be missing something?
is...@gmail.com <is...@gmail.com> #4
@marc.art: The validation still validates within the UI itself; it's just that the results of the validation aren't available in code.
[Deleted User] <[Deleted User]> #5
This would be extremely helpful! Im looking to optimize my team's workflow and it is counterintuitive and wasteful on resources to reverse engineer the validation just to check if it is valid when that information is already shown in the UI! Please add .isValid()!!
os...@gmail.com <os...@gmail.com> #6
This is a blocking feature for implementing a compliance changelog of only valid entries.
ni...@gmail.com <ni...@gmail.com> #8
Can't see why this isn't already available. I hope it is added soon!
pa...@saw-office.net <pa...@saw-office.net> #9
I've created a workaround for this issue that works in a very ugly -technically said- and slightly undetermined way.
My problem is that the validation is already done by the SpreadsheetApp, but only visually accessible by the user. It feels like that "you can see but cannot touch" :) It's against the whole idea of GAS.
I'd really love to have this result accessible (the feature implemented).
About the workaround:
It works based on the experience that the web browser implementation of catch() function allows to access thrown errors by the script editor JS code parts.
In case an invalid input into a cell is rejected by a validation rule then the system will display an error message that is catchable by the user written GAS. In order to make it work first the reject value has to be set on the specified cell then its vale has to be re-entered (modified) then -right after this- calling the getDataValidation() built in function allows us to catch the necessary error.
Only single cells can be tested with this method as setCellValues() ignores any data validation restriction (as of today).
Disadvantages:
- The validity won't be necessarily re-checked for this function: checking cell validity right after the value is inserted into it. Therefore the result of this function might be faulty.
- The code messes up the history as cells will be changed - in case they are valid.
I've tested it successfully on both Firefox and Chromium.
function getCellValidity(cell) {
var origValidRule = cell.getDataValidation();
if (origValidRule == null || ! (cell.getNumRows() == cell.getNumColumns() == 1)) {
return null;
}
var cell_value = cell.getValue();
if (cell_value === '') return true; // empty cell is always valid
var is_valid = true;
var cell_formula = cell.getFormula();
// Storing and checking if cell validation is set to allow invalid input with a warning or reject it
var reject_invalid = ! origValidRule.getAllowInvalid();
// If invalid value is allowed (just warning), then changing validation to reject it
// IMPORTANT: this will not throw an error!
if (! reject_invalid) {
var rejectValidRule = origValidRule.copy().setAllowInvalid(false).build();
cell.setDataValidation(rejectValidRule);
}
// Re-entering value or formula into the cell itself
var cell_formula = cell.getFormula();
if (cell_formula !== '') {
cell.setFormula(cell_formula);
} else {
cell.setValue(cell_value);
}
try {
var tempValidRule = cell.getDataValidation();
} catch(e) {
// Exception: The data that you entered in cell XY violates the data validation rules set on this cell.
// where XY is the A1 style address of the cell
is_valid = false;
}
// Restoring original rule
if (rejectValidRule != null) {
cell.setDataValidation(origValidRule.copy().setAllowInvalid(true).build());
}
return is_valid;
}
Finally let me express my gratitude for all the great works of the developers! With their shared tools/system I can solve many logistical problems of my and others' lives... Cheers!
On this issue: Hurry up guys!
My problem is that the validation is already done by the SpreadsheetApp, but only visually accessible by the user. It feels like that "you can see but cannot touch" :) It's against the whole idea of GAS.
I'd really love to have this result accessible (the feature implemented).
About the workaround:
It works based on the experience that the web browser implementation of catch() function allows to access thrown errors by the script editor JS code parts.
In case an invalid input into a cell is rejected by a validation rule then the system will display an error message that is catchable by the user written GAS. In order to make it work first the reject value has to be set on the specified cell then its vale has to be re-entered (modified) then -right after this- calling the getDataValidation() built in function allows us to catch the necessary error.
Only single cells can be tested with this method as setCellValues() ignores any data validation restriction (as of today).
Disadvantages:
- The validity won't be necessarily re-checked for this function: checking cell validity right after the value is inserted into it. Therefore the result of this function might be faulty.
- The code messes up the history as cells will be changed - in case they are valid.
I've tested it successfully on both Firefox and Chromium.
function getCellValidity(cell) {
var origValidRule = cell.getDataValidation();
if (origValidRule == null || ! (cell.getNumRows() == cell.getNumColumns() == 1)) {
return null;
}
var cell_value = cell.getValue();
if (cell_value === '') return true; // empty cell is always valid
var is_valid = true;
var cell_formula = cell.getFormula();
// Storing and checking if cell validation is set to allow invalid input with a warning or reject it
var reject_invalid = ! origValidRule.getAllowInvalid();
// If invalid value is allowed (just warning), then changing validation to reject it
// IMPORTANT: this will not throw an error!
if (! reject_invalid) {
var rejectValidRule = origValidRule.copy().setAllowInvalid(false).build();
cell.setDataValidation(rejectValidRule);
}
// Re-entering value or formula into the cell itself
var cell_formula = cell.getFormula();
if (cell_formula !== '') {
cell.setFormula(cell_formula);
} else {
cell.setValue(cell_value);
}
try {
var tempValidRule = cell.getDataValidation();
} catch(e) {
// Exception: The data that you entered in cell XY violates the data validation rules set on this cell.
// where XY is the A1 style address of the cell
is_valid = false;
}
// Restoring original rule
if (rejectValidRule != null) {
cell.setDataValidation(origValidRule.copy().setAllowInvalid(true).build());
}
return is_valid;
}
Finally let me express my gratitude for all the great works of the developers! With their shared tools/system I can solve many logistical problems of my and others' lives... Cheers!
On this issue: Hurry up guys!
ro...@gmail.com <ro...@gmail.com> #10
I'm desperate for this method to be added! Please please please do it soonest possible! Thank you!
vl...@gmail.com <vl...@gmail.com> #11
Yes please implement this. I suppose the data could be checked against the data validation rules before setting the values, but that would really slow the write process down. Not to mention how much of a pain it would be to code all the validity checks to accommodate all the different possible data validation rules.
I've been starting to use Google Sheets to serve some of our company's data storage in place of data typically stored in a SQL database, but the hard data validation rules are an essential part to maintaining data integrity in the way that's possible with a SQL database.
I've been starting to use Google Sheets to serve some of our company's data storage in place of data typically stored in a SQL database, but the hard data validation rules are an essential part to maintaining data integrity in the way that's possible with a SQL database.
br...@gmail.com <br...@gmail.com> #12
Please add this. It will bring down so much bad code that I have put in place due to lack of this function.
ek...@google.com <ek...@google.com> #13
Please add this in asimple manner: isValid() true or false
vl...@gmail.com <vl...@gmail.com> #14
I would say the methis should be intiutive to read.
Range.dataValidate() :: [][]bool
Since we are doing DataValidations ...
Range.dataValidate() :: [][]bool
Since we are doing DataValidations ...
vl...@gmail.com <vl...@gmail.com> #15
I need it like a thirsty desert traveler needs a few drops of water.
os...@gmail.com <os...@gmail.com> #16
I need it like a few drops of water need hydrogen and oxygen
vl...@gmail.com <vl...@gmail.com> #17
Must I beg?
vl...@gmail.com <vl...@gmail.com> #18
Seems that begging is necessary...
Description
Search for folder by means of
drive.files().list().setQ(query)
with non latin name gives nothing when such folder definitely exists!
What API version are you using ?
I am using V2 of Google Drive API by means of following libs:
com.google.apis:google-api-services-drive:v2-rev154-1.18.0-rc
com.google.api-client:google-api-client:1.18.0-rc
com.google.api-client:google-api-client-android:1.18.0-rc
com.google.http-client:google-http-client:1.18.0-rc
com.google.http-client:google-http-client-gson:1.18.0-rc
A small code sample that reliably reproduces the issue.
private IFile getChildByName(Drive drive, String childName){
IFile childFile = null;
String query = "'" + getMetaData().getId() + "' in parents and title='" + childName + "' and trashed=false";
Drive.Files.List request = null;
try {
request = drive.files().list().setQ(query);
} catch (IOException e) {
e.printStackTrace();
}
List<File> childList = new ArrayList<File>();
if (request != null) {
do {
try {
FileList children = request.execute();
childList.addAll(children.getItems());
request.setPageToken(children.getNextPageToken());
} catch (IOException e) {
System.out.println("An error occurred: " + e);
request.setPageToken(null);
}
} while (request.getPageToken() != null && request.getPageToken().length() > 0);
childFile = childList.isEmpty() ? null : new GoogleDriveFile(childList.get(0), this);
}
return childFile;
}
What steps will reproduce the problem?
1. Create Google Drive account and two folders in the root with latin ("Archive") and non latin (cyrillic - "Архив") names.
2. Make a search query
drive.files().list().setQ("'root' in parents and title='Archive' and trashed=false").execute()
and get metadata of "Archive" folder.
Then make other quey
drive.files().list().setQ("'root' in parents and title='Архив' and trashed=false").execute()
and get nothing!
Question:
Is it a bug or should I use some encoding for non latin characters in the searched name? If last where does Google mention it in their docs!?
Details are here