function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Jim MontgomeryJim Montgomery 

Invalid bind expression type of Case for column of type Id

Invalid bind expression type of Case for column of type Id line 9

public class CaseAMSInventory {
Public Case CaseAcct{get;set;}
    

      transient Public List<AMS_Inventory_Rollup__c> CI{get;set;}
             
                 public CaseAMSInventory(ApexPages.StandardController controller) {
                     CaseAcct=[select AccountID from case where ID = :ApexPages.currentPage().getParameters().get('id') ];
          CI=[select id,(select id,name,product_name__c,quantity__c, PFX_Account_Number__c from AMS_Inventory_Rollups__r where accountID__c =:CaseAcct ) from Case where ID=:ApexPages.currentPage().getParameters().get('id') ];
                     
         // System.Debug('CI: ' + CI.get(0));
        //System.Debug('Inventory: ' + CI.get(0).AMS_Inventory_rollups);
        
}

}


 
Best Answer chosen by Jim Montgomery
Maharajan CMaharajan C
Hi Jim,

public class CaseAMSInventory {
Public Case CaseAcct{get;set;}
    

      transient Public List<AMS_Inventory_Rollup__c> CI{get;set;}
             
     public CaseAMSInventory(ApexPages.StandardController controller) {
     CaseAcct=[select AccountID from case where ID = :ApexPages.currentPage().getParameters().get('id') ];
     List<case> Caserecord=[select id,(select c.id,c.name,c.product_name__c,c.quantity__c,c.PFX_Account_Number__c from AMS_Inventory_Rollups c) from Case where ID=:ApexPages.currentPage().getParameters().get('id') ];   //  use the relationship name for get the child records
                     
        if(!CI.isEmpty())
        CI.addAll(Caserecord[0].AMS_Inventory_Rollups);  ////  use the relationship name for get the child records
}

}

if you have any doubt refer this link: https://salesforce.stackexchange.com/questions/103935/accessing-subquery-from-visualforce-page


Can you please Let me know if it helps or not!!!

If it helps don't forget to mark this as a best answer!!!


Thanks,
Raj

All Answers

Maharajan CMaharajan C
Hi Jim,

public class CaseAMSInventory {
Public Case CaseAcct{get;set;}
    

      transient Public List<AMS_Inventory_Rollup__c> CI{get;set;}
             
     public CaseAMSInventory(ApexPages.StandardController controller) {
     CaseAcct=[select AccountID from case where ID = :ApexPages.currentPage().getParameters().get('id') ];
     List<case> Caserecord=[select id,(select c.id,c.name,c.product_name__c,c.quantity__c,c.PFX_Account_Number__c from AMS_Inventory_Rollups c) from Case where ID=:ApexPages.currentPage().getParameters().get('id') ];   //  use the relationship name for get the child records
                     
        if(!CI.isEmpty())
        CI.addAll(Caserecord[0].AMS_Inventory_Rollups);  ////  use the relationship name for get the child records
}

}

if you have any doubt refer this link: https://salesforce.stackexchange.com/questions/103935/accessing-subquery-from-visualforce-page


Can you please Let me know if it helps or not!!!

If it helps don't forget to mark this as a best answer!!!


Thanks,
Raj
This was selected as the best answer
Prashant Pandey07Prashant Pandey07
Hello Jim,

There is a problem in line 9 where you are trying to query child to Parents record but the query is not written in the correct way.
 
public class CaseAMSInventory {
Public Case CaseAcct{get;set;}
    

      transient Public List<AMS_Inventory_Rollup__c> CI{get;set;}
             
     public CaseAMSInventory(ApexPages.StandardController controller) {
     CaseAcct=[select AccountID from case where ID = :ApexPages.currentPage().getParameters().get('id') ];
     
     CI=[Select id,Case__c,product_name__c,quantity__c, PFX_Account_Number__c from AMS_Inventory_Rollup__c where Case__r.id=:CaseAcct.id];
//Query for child to get the pareants where case__c is the lookup field to relate AMS_Inventory_Rollup__c
    
     List<case> Caserecord=[select id, (select id,name, from AMS_Inventory_Rollups__r) from Case where ID=:ApexPages.currentPage().getParameters().get('id') ];  
        if(!CI.isEmpty())
        CI.addAll(Caserecord[0].AMS_Inventory_Rollups__r); 
}
}

--
Thanks,
Prashant