function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
ying liuying liu 

error about retrieve records in VF remote objects with lookup fields

I have created a VF with some remote objects.
I want to retrieve records from those objects with lookup fields.
But there is an error which is “Invalid criteria specified for retrieval. ValidationError [code=11, message=Data does not match any schemas from "oneOf", path=/where, schemaKey=null]".
Other fields can be queryed except for lookup.

Below is my code in VF.
var existAtt = new SObjectModel.ExistAttendee();
existAtt.retrieve({ where : {Account_vod__c: {eq: 'a0pK0000000XAYvIAO' }}}, function(err, records){
if(err) {
   alert(err.message);
}else{alert("ok");}
});

Please help me about this!
Thanks much!
Best Answer chosen by ying liu
ying liuying liu
Thanks much!
I have found the reason and which is the query field must be in fields of remoteobjectmodel.
I added Account_vod__c to fields and it works.
<apex:remoteObjectModel name="Attendee_vod__c" jsShorthand="ExistAttendee" fields="Id,Name,Account_vod__c">
</apex:remoteObjectModel>


All Answers

Vamsi KrishnaVamsi Krishna
Ying,
seems you are trying to retrieve records for ExistAttendee (a custom object) , so you should have __c for the object name

var existAtt = new SObjectModel.ExistAttendee__C();
existAtt.retrieve({ where : {Account_vod__c: {eq: 'a0pK0000000XAYvIAO' }}}, function(err, records){
if(err) {
   alert(err.message);
}else{alert("ok");}
});
ying liuying liu
Hi,

Thanks for your answer.
ExistAttendee is an alias name about a custom object. And I am sure ExistAttendee is ok.
I have used remote object which is like this:
<apex:remoteObjectModel name="Attendee_vod__c" jsShorthand="ExistAttendee" fields="Id,Name">
</apex:remoteObjectModel>

Ashish_SFDCAshish_SFDC
Hi, 


The lookup field has to be called with Reference, 

CurrentObject__r.LookupObject__c.RecordName 


Regards,
Ashish
ying liuying liu
Thanks much!
I have found the reason and which is the query field must be in fields of remoteobjectmodel.
I added Account_vod__c to fields and it works.
<apex:remoteObjectModel name="Attendee_vod__c" jsShorthand="ExistAttendee" fields="Id,Name,Account_vod__c">
</apex:remoteObjectModel>


This was selected as the best answer
M BestM Best
Thanks for saving me a lot of time!
James JS KennyJames JS Kenny
Hit this myself, but the problem was the case sensitivity in the remote object declaration.
 
<apex:remoteObjectModel name="ContentVersion" jsShorthand="cVersion" fields="Id,ContentDocumentId,isLatest">

But when querying:
 
{where:{
                ContentDocumentId:{in:vDocs},
                IsLatest:{eq:true}
              }
}

the problem was the 'i' in IsLatest.