Print this page

Remote Objects issue with more than 2 query conditions

Knowledge Article Number 000213750
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: 
var Qry = { 
	where: 
	{ 
		and: 
		{ 
			accountId: { eq: '{!Opportunity.AccountId}'}, 
			IsClosed: {eq: false}, 
			NextStep: {eq:'review'}
		} 
	} 
};

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: 
var Qry = { 
	where: { 
		accountId: { eq: '{!Opportunity.AccountId}'}, 
		NextStep: {eq:'review'}, 
		StageName: {eq:'Prospecting'}, 
		LeadSource: {eq:'Web'}, 
		IsClosed: {eq: false} 
	} 
};

There is no work around for "OR"




promote demote