Imagine you want to add a custom button (Apex based, no JS) to the Related Contacts list on an Account detail page. To perform the buttons action you need some information of the parent Account.
Page
<apex:page standardController="Contact" extensions="ContactAction_CtrlExt"
recordSetVar="contacts" action="{!doAction}">
</apex:page>
Controller class
public with sharing class ContactAction_CtrlExt {
private Account account;
private List<Contact> relatedContacts;
// CONSTRUCTOR
public ContactAction_CtrlExt(ApexPages.StandardSetController standardSetController) {
account = ...???...;
relatedContacts = (List<Contact>) standardSetController.getRecords();
}
// ACTION METHOD
public PageReference doAction() {
doSomething(account, relatedContacts);
}
}
Is there a way to access the account in the Controller Extension code of your list button?
