0

I want to show all related cases of account record in visualforce page embeded to layout.

What is main issue? Standard Account object has related cases. Also Account has related Asset and Contact object, where both of them also owns some cases. That cases are related with account by AccountId fields, so are related with account too.

I dont know how to make my Visualforce page from scratch. I dont know much about so advanced techniques in standard controllers extensions.

1

OK! I've solved my problem!

Standard Account Controller Extension code:

public class Extension1 {

private Account account;

public Extension1(ApexPages.StandardController stdContr){
    this.account = (Account)stdContr.getRecord();
}

public List<Case> getRelatedCases(){

    return [select casenumber, subject from case where accountid=:account.Id 
                               or contact.accountid=:account.Id 
                               or asset.accountid=:account.Id];
}

}

And Visualforce code with tab tag getting list of accounts with accountid.

0

So if you want to find out all case which are only related to Account but not with Case and Asset.

You can put query like

[Select Id from case where accountId = 'YourId' and AssetId == null && ContactId == null]

This query will only return Case which is related to your Account.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.