2

I have an issue with remote objects: I run the following code:

<apex:remoteObjectModel name="Case" jsShorthand="case" 
                    fields="Subject,Id,CaseNumber,CreatedDate,Status,Description,IsClosed,Priority,Type"/>

    var cases = new SObjectModel.Case();
    cases.retrieve({where: {IsClosed: {eq: false}}}
    , function(error, records) {
    });

and the error is:

Error occurred while performing RETRIEVE operation on sobject: Case with data: {where={IsClosed={eq=true}}} (MALFORMED_QUERY: 
subject, createddate, id, casenumber, _cid FROM Case WHERE IsClosed =
                                     ^
ERROR at Row:1:Column:76
line 1:76 no viable alternative at character '_') 

Well, yesterday it was working ok. What can be wrong with this part?

1 Answer 1

4

I couldn't find much detail in the "official" documentation, but did come across this gist that illustrates many patterns.

The only "query by a specific id" pattern I could get to work is this one:

<apex:page >
    <apex:remoteObjects>
        <apex:remoteObjectModel name="Account" jsShorthand="Account" fields="Name,Id"/>
    </apex:remoteObjects>
    <script>
        fetch = function(){
            var a = new SObjectModel.Account();
            a.retrieve({where: {Id: {eq: "001i000000cwvW9AAI"}}}, function(err, records){
                if(err) alert(err.message);
                else {
                    records.forEach(function(record) {
                        console.log(JSON.stringify(record));
                    });
                }
            });
        };
    </script>
    <button onclick="fetch()">Fetch</button>
</apex:page>

which is like your first example except that it works... Your error message doesn't seem to reflect the "where" that you list; is it possible some other code is causing your error?

1
  • As I said it was working ok a day before
    – Natallia
    Commented May 21, 2014 at 7:08

You must log in to answer this question.

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