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
Doug Beltowski XDoug Beltowski X 

Remote Object Query not respecting multiple conditions on single field

I'm trying to utilize Remote Objects in order to query a Custom Object.  My JSON criteria are below. My query returns data, the problem is that the first Custom_Date_Time__c field criteria is ignored.  As shown it will return all objects with date before January 1st 2016, and if I switch the lines it will return all objects with the date after January 1st 2014.  What I need are all objects with the date between these two.
{
	where:
	{
		RecordTypeId: {in: ids},
		Custom_Boolean__c: {eq: true},
		Custom_Date_Time__c: {gte: new Date('2014-1-1')},
		Custom_Date_Time__c: {lte: new Date('2016-1-1')}
	},
	limit: 100
}
Is this a bug/limitation with Remote Objects, or is my query somehow malformed?
 
Best Answer chosen by Doug Beltowski X
Doug Beltowski XDoug Beltowski X
Figured out the problem.  The JSON criteria needed to be structured in a special way due to having the same field twice.
{
	where:
	{
		and:
		{
			Custom_Date_Time__c: {gte: new Date('2014-1-1')},
			and:
			{
				Custom_Date_Time__c: {lte: new Date('2016-1-1')},
				and:
				{
					RecordTypeId: {in: ids},
					Custom_Boolean__c: {eq: true}
				}
			}
		}
	},
	limit: 100
}

The following format returned the records that I wanted.