5

I just started programming in apex, so I will appreciate your help in this case. This class should allow me to get the bundle_Items from bundle object where Bundle__c =(Here is the result of the 'values', which returning the correct Ids, I already tested it). I don't know if I am doing something wrong in the second query, or there might be another approach for the IN: values.

"Error: Compile Error: Invalid bind expression type of SOBJECT:Purchase_Order_Details__c does not match domain of foreign key at line 19 column 79"

Thank you so much in advance!

public class  PO_Vendor_Controller_BundleItems {

    public ApexPages.StandardController std2;
    public List<o_Bundle__c> PODetails2 {get; set;}  
    Public List<Purchase_Order_Details__c> values {get;set;}    

    public PO_Vendor_Controller_BundleItems (ApexPages.StandardController stdCtrl2){
        std2=stdCtrl2; 
        List<Purchase_Order_Details__c> values = [SELECT ProductId__c 
                                                  FROM Purchase_Order_Details__c 
                                                  WHERE PO_ID__c =:std2.getId()]; 
        String[] contractIDs = new string[values.size()]; 

        for (integer i=0; i<values.size(); i++){
             contractIDs[i] = values[i].ProductId__c;
        }
        PODetails2 = [SELECT Bundle_Item__c 
                      FROM o_Bundle__c 
                      WHERE Bundle__c IN:contractIDs ]; 
    }//END init(ApexPages.StandardController stdCtrl2)

}//END PO_Vendor_Controller_BundleItems 

Update - above Constructor updated

4
  • 1
    What is the field type of Bundle__c on o_Bundle__c? I suspect it is lookup to o_Bundle__c right? I tested a similar query from case to user and it worked fine. I usually use Ids instead of whole objects when filtering like this, but from the test I ran it should work fine as long as Bundle__c is a relationship to o_Bundle__c.
    – drakored
    Feb 13, 2014 at 1:11
  • It is a lookup. I found a solution in case others are having the same issue:
    – Carlos
    Feb 13, 2014 at 16:03
  • public PO_Vendor_Controller_BundleItems (ApexPages.StandardController stdCtrl2) { std2=stdCtrl2; List<Purchase_Order_Details__c> values = [SELECT ProductId__c FROM Purchase_Order_Details__c WHERE PO_ID__c =:std2.getId()]; String[] contractIDs = new string[values.size()]; for (integer i=0; i<values.size(); i++) { contractIDs[i] = values[i].ProductId__c ; } PODetails2 = [SELECT Bundle_Item__c FROM o_Bundle__c WHERE Bundle__c IN:contractIDs ]; } }
    – Carlos
    Feb 13, 2014 at 16:04
  • What line is causing the error? (what's going on in the ErrorLine?) Feb 14, 2014 at 18:31

1 Answer 1

0

In where clause you have used field 'PO_ID__c'. Make sure that this field is lookup or master-detail field and this field looks up to the SObject mentioned in standardController attribute on VF page.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .