You need to sign in to do that
Don't have an account?
VT878
Remote Object and WHERE condition
Hi, I have a problem with Remote Object.
If I use one logical operator is all ok. The problems is present when I use more logical operator (for example: OR[AND(condition1, condition2), AND(condition3, condition4)]
The error message is: "Error: Invalid criteria specified for retrieval. ValidationError [code=11, message=Data does not match any schemas from "oneOf", path=/where, schemaKey=null]"
My code is here:
If I use one logical operator is all ok. The problems is present when I use more logical operator (for example: OR[AND(condition1, condition2), AND(condition3, condition4)]
The error message is: "Error: Invalid criteria specified for retrieval. ValidationError [code=11, message=Data does not match any schemas from "oneOf", path=/where, schemaKey=null]"
My code is here:
var contatti = new SObjectModel.Contact(); var criteria = {}; var results = []; var criteria = {}; var firstString = 'test1'; var secondString = 'test2'; criteria.where = { or: { and: { FirstName: {like: firstString + '%'}, LastName: {like: secondString + '%'} }, and: { FirstName: {like: secondString + '%'}, LastName: {like: firstString + '%'} } } contatti.retrieve( criteria, function(err, records, event) { if(err) console.log('errore:'+err); if(!err) { for (var i = 0; i < records.length; i++) { results.push({ label: records[i].get('LastName') + ' ' + records[i].get('FirstName'), id: records[i].get('Id') }); } callback(results); } } );Thanks!!!
First and foremost sincerely regret for the delayed reply.
Description:When using Visual Force Remote Objects, if a Query is formulated with "AND" clause, it takes only 2 predicates.
If more than 2 predicates are specified , such as in the code below, the following error is thrown: Error Message:"Error: Invalid criteria specified for retrieval. ValidationError [code=11, message=Data does not match any schemas from "oneOf", path=/where, schemaKey=null]"
Resolution:This is working as expected since "AND" ( and "OR") logical operator must have 2 objectives.
As a workaround for "AND" to work with multiple filters , syntax mentioned in the following code can be used: Hope this helps.
Mark this as solved if it's resolved.
Best Regards,
Nagendra.P