This error is killing me :(
Semi join sub-selects are only allowed at the top level WHERE expressions and not in nested WHERE expressions
(or)
Semi join sub-selects are not allowed with the 'OR' operator
Here is my code. Can someone help?
Note :- I can't convert the select query that I have written in my where clause to a seperate query (Where Id in (select.... ) and get the data in an id set and substitute in the below query, because my id set has about 35000 records and when I try to query with that set it throws a Time limit exceeded error as it is unable to handle even more than a 1000 or 2000 records in a set if it is in an SOQL IN clause.
And I have just given a sample code here by getting the count, I need to get the count as well as the actual data..
Id CompanyId = '001Z000000CF2PtIAL';
String SearchText = '%test%';
Set<Id> SearchgroupassetidSet = new Set<ID>();
SearchgroupassetidSet.add('a7aZ00000004CHhIAM');
SearchgroupassetidSet.add('a7aZ00000004CHiIAM');
SearchgroupassetidSet.add('a7aZ00000004CHjIAM');
SearchgroupassetidSet.add('a7aZ00000004CHkIAM');
Integer RecCount=0;
List<AggregateResult> lstaggResult = [Select count(id) RecCount FROM Asset__c where Id IN (Select Asset__c from Customer_Asset__c where isDeleted =false and Company__c =: CompanyId and (Asset__r.Title__c like : SearchText or Asset__r.Name like : SearchText))
or (Group__c IN : SearchgroupassetidSet and ((Title__c like : SearchText) or (Name like : SearchText)))];
if (lstaggResult.size() > 0)
{
RecCount = (Integer)lstaggResult[0].get('RecCount');
}
System.debug('Record Count : ' + RecCount);