You need to sign in to do that
Don't have an account?
Problem with IN operator error message
The system is throwing this error:FATAL_ERROR System.QueryException: IN operator must be used with an iterable expression.
The Query string is:
string findTestPOs = 'SELECT id, name,Finalized__c,PO_Notes__c,Status__c, Ship_to_location__c, Expedite__c, PO_Date__c, Total_Price__c,Category__c,SFDC_Purchase_Order__c.ownerID FROM SFDC_Purchase_Order__c WHERE id in :MyPOIdSet';
The lines throwing the error are:
List<SFDC_Purchase_Order__c>myNewPOs = new List<SFDC_Purchase_Order__c>();
myNewPOs = database.query(FindTestPOs);
I have 2 questions:
What can I do to fix this error?
How can a Set not be iterable?
This reallly has me puzzled. This is keeping my Test code from running to completion.
I really appreciate any insight anyone has.
Thank you very much.
Kathybb
Can you please share the declaration of the variable MyPOIdSet. Also the binding is done when you call the Database.query, not while forming the string. So for any reason if the declaration is out of scope you may get this error. Below is one working code snippet. Please see if this helps.
List<Account> la = [Select Id From Account];
String str = 'Select Id From Account Where Id in :la';
System.debug(str);
System.debug(Database.query(str));
you can run query using following
Please fill MyPOIdSet with SFDC_Purchase_Order__c Id's
string findTestPOs = 'SELECT id, name,Finalized__c,PO_Notes__c,Status__c, Ship_to_location__c, Expedite__c, PO_Date__c, Total_Price__c,Category__c,SFDC_Purchase_Order__c.ownerID FROM SFDC_Purchase_Order__c
WHERE id = :MyPOIdSet';
this fix will help you
Thank you so much for your time and help..
Thank you so much for your time and help..