1

I'm trying to utilize Remote Objects in order to query a Custom Object. Part of my criteria involves getting all records during a particular date range off of a single field.

{
    where:
    {
        Custom_Date_Time__c: {gte: new Date('2014-1-1')},
        Custom_Date_Time__c: {lte: new Date('2016-1-1')}
    },
    limit: 100
}

My query returns records but only the second listed Custom_Date_Time__c criteria is respected. So as it is written now it will return all records with Custom_Date_Time__c earlier than January 1st, 2016. If I switch the the lines to

{
    where:
    {
        Custom_Date_Time__c: {lte: new Date('2016-1-1')},
        Custom_Date_Time__c: {gte: new Date('2014-1-1')}
    },
    limit: 100
}

then I will get all records with Custom_Date_Time__c after January 1st, 2014.

I found this SE Question asking about combining and: and or: that might suggest the solution to my problem is formatting my JSON object in a certain manner, but my attempts to do so have all resulted in errors.

  • Are you certain you get dates lt 2014-1-1 in the first case and gt 2016-1-1 in the second? – Adrian Larson Jan 10 '16 at 23:28
0

the link you sent in your question is your answer unfortunately - as far as I know - so in your case you need to make up another criteria and use AND:

var options = {
  where: {
    and: {
      Custom_Date_Time__c: {lte: new Date('2016-1-1')},
      and: {
       Custom_Date_Time__c: {gte: new Date('2014-1-1')},
       Id: {ne: '123'}
      }
    }
  },
  limit: 100

}

Hope this helps!

  • Florian

If you are using AngularJS with RemoteObjects have a look at ngRemote

| improve this answer | |
  • I've not been using Angular but I do intend to look into it in the near future. I'll also take a look at ngRemote. Thanks. – dBeltowski Jan 13 '16 at 14:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.