Potential Bug with Model Conditions/ Grouping Logic?

Hi Mark,

It is happening regardless of which condition is the final one in the list. You can see above in my first example it was the ‘end date = null’ condition, but in my most recent comment the final condition is the ‘operator = I&M’, either way I am getting the errors (I have tried switching the order of the conditions many times including putting all the ANDs first, putting them in numerical order etc.).

Here is another example for you. I put the ‘starting month != 5’ condition at the end and adjusted grouping logic:

1: An error occurred while attempting to perform the following SOQL query: SELECT Registration__c,Registration__r.Name,Registration__r.Registration_Status__c,Program__c,Registration__r.Site__c,Registration__r.Site__r.Name,Registration__r.Site__r.Id,Operator__c,Begin_Date__c,End_Date__c,Expected_Capacity__c,Site__c,Site__r.Name,Site__r.Address_Line_1__c,Zone__c,Id FROM Capacity_History__c WHERE (Registration__r.Site__r.Id in (‘aA64v000000D2ixCAC’,‘aA64v000000D2iyCAC’,‘aA64v000000D2izCAC’,‘aA64v000000D2j0CAC’,‘aA64v000000D2j1CAC’,‘aA64v000000D2j2CAC’,‘aA64v000000D2j3CAC’,‘aA64v000000D2j4CAC’,‘aA64v000000D2j5CAC’,‘aA64v000000D2j6CAC’,‘aA64v000000D2j7CAC’,‘aA64v000000D2j8CAC’,‘aA64v000000D2j9CAC’,‘aA64v000000D2jACAS’,‘aA64v000000D2jBCAS’,‘aA64v000000D2jCCAS’,‘aA64v000000D2jDCAS’,‘aA64v000000D2jECAS’,‘aA64v000000D2jFCAS’,‘aA64v000000D2jGCAS’))AND(Registration__r.Registration_Status__c != ‘0. Retired’)AND((Program__c = ‘Emergency Load Response Program’)OR(Operator__c = ‘I&M’))AND(Begin_Date__c <= N_MONTHS_AGO:12)AND((End_Date__c >= N_MONTHS_AGO:12)OR(End_Date__c = null))AND8 ORDER BY Program__c, Zone__c, Site__c, Begin_Date__c,Id Error:unexpected token: AND8

(XML in the following comment - you can see that no matter what the final item is it is not reading it correctly)