2

I've tried using an AND condition in my remote object. I keep getting an error. Here is what I have based on a help article. It works when there is only a single condition. Once I add two it doesn't work.

// On my VF page
// <apex:remoteObjects >
//    <apex:remoteObjectModel name="Group" fields="Id,Name" />
// </apex:remoteObjects>


    var queue = new SObjectModel.Group();
    var criteria = {
                    where: {
                      Name: {like: event.target.value +'%'},
                      Type: {eq: 'Queue'}
                    }
                   };
    queue.retrieve( criteria, function(err, records, event) {
      if (err) {
        alert(err.message);
      }
      var records = event.result.records;
      console.log(records);
    })
1
  • What error are you getting?
    – sfdcfox
    Feb 12, 2017 at 23:55

1 Answer 1

5

I presume you're getting the following error:

Invalid criteria specified for retrieval. ValidationError [code=11, message=Data does not match any schemas from "oneOf", path=/where, schemaKey=null]


You can only specify fields to filter if they are specified as part of the remoteObjectModel. You need to change your code as follows:

<apex:remoteObjects >
   <apex:remoteObjectModel name="Group" fields="Id,Name,Type" />
</apex:remoteObjects>

As a side note, it's not necessary to assign event.target.records to a variable; that's what the records variable returns anyways.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .