+ Start a Discussion
di_zoudi_zou 

Having trouble getting ALL the cases of an account

I am trying to make a custom page in my Customer Portal that shows ALL the cases of an account instead of just that specific user's. I received some help from another user on this board and he recommended I do this in my custom controller:

 

    Id accountId = [SELECT Contact.AccountId FROM User WHERE Id = :UserInfo.getUserId()].Contact.AccountId;
    List<Case> results = [SELECT Id, CaseNumber FROM Case WHERE AccountId = :accountId];

 

However, this does not return ALL the cases for the user's account. This still only returns the cases that the user himself opened. I am looking to get a list of cases that other users that are part of the account have opened as well. What am I missing here? Thanks!

Best Answer chosen by Admin (Salesforce Developers) 
Saikishore Reddy AengareddySaikishore Reddy Aengareddy

In your controller class have you used "With sharing"? If yes remove or make it to without sharing and see if it helps.

All Answers

Saikishore Reddy AengareddySaikishore Reddy Aengareddy

In your controller class have you used "With sharing"? If yes remove or make it to without sharing and see if it helps.

This was selected as the best answer
di_zoudi_zou

This worked, thanks!