You need to sign in to do that
Don't have an account?
Hari N 20
IN operator must be used with an iterable expression
Hi All,
I am getting error as following : IN operator must be used with an iterable expression .
My code is :
List<Task> ts1=[Select Id,WhoId from Task];
for(Task ts2 : ts1){
Map<ID, Obj1__c> mapAccounts = new Map<ID, Obj1__c>([SELECT Id, Name, Filed1__c FROM Obj1__c WHERE Field1__r.Id IN: ts2.whoId]);
}
Filed1__c is lookup to account.
How to resolve this?
Thanks in Advance
I am getting error as following : IN operator must be used with an iterable expression .
My code is :
List<Task> ts1=[Select Id,WhoId from Task];
for(Task ts2 : ts1){
Map<ID, Obj1__c> mapAccounts = new Map<ID, Obj1__c>([SELECT Id, Name, Filed1__c FROM Obj1__c WHERE Field1__r.Id IN: ts2.whoId]);
}
Filed1__c is lookup to account.
How to resolve this?
Thanks in Advance
All Answers
Use below SOQL query instead
[SELECT Id, Name, Filed1__c FROM Obj1__c WHERE Field1__r.Id = :ts2.whoId]
Thank you for your reply.
Its working.
Now, when I am inserting recording in custom object I am getting this error : System.LimitException: Too many SOQL queries: 101
I am getting the below error can any one help to resolve.
ERROR: IN operator must be used with an iterable expression
My code is:
List<Region__c> regionsList = [Select id, Single_Dose_Users__c, Two_Dose_Users__c, Total_Users__c from Region__c where Id In:singleDoseIncrease OR Id In:singleDoseDecrease Or Id In:doubleDoseIncrease Or Id In:increaseUserCount];
for(Region__c indRegion: regionsList)