+ Start a Discussion
Pawan RaiPawan Rai 

Case controller is not working

Hey Guys,


I want to show all the case which is related to Account in Case Page. For that i created Page and controller, but the problem is, controller is picking all the Case, not related to Particular Account.

Here is the code:

List<Case> caselist = new List<Case>();
public List<Case> getmyCase()
    caselist = [select Subject, AccountId, Origin, Status, Product__c, CaseNumber from Case where AccountId =:ApexPages.CurrentPage().getParameters().get('Account.id')];
         return caselist;


Outcomes: Its picking all the case, not related to specific Account.


Can any one help me on that.



That's very odd - your query should be pulling only those that match the account id.


Can you post the URL that you use to open the page?

Ritesh AswaneyRitesh Aswaney

Can you confirm that AccountId is being passed in as a query parameter.

It might be an idea to System.debug the AccountId value, and it may be querying for a null value and returning cases which are not associated with an Account