I want to use an extension to override the standard contoller of a custom object (DetailContact), which is the detail object in a master-detail relationship with Contact.

<apex:page standardController="DetailContact__c" extensions="myExtension">

public myExtension(ApexPages.StandardController controller)

When loading the page, I got:

Error occurred while loading a Visualforce page.

FYI, when I use:

<apex:page standardController="DetailContact__c" recordSetVar="ContactDetails" extensions="myExtension">

public myExtension(ApexPages.StandardSetController controller)

There is no error, but I don't understand why I would use recordSetVar parameter since I don't manipulate a list of DetailContact__c.

Moreover, I wand to use the standard save button, so I mustn't use a list controller.

Do you know a workaround ? Thanks.

  • Did you pass any ID in the URL during the first scenario? Commented Nov 18, 2015 at 11:06
  • @SantanuHalder The page is called from a list button (which is located in the Contact detail page, in the DetailContact related list section). So the Url contains the id of the contact.
    – yassine
    Commented Nov 18, 2015 at 11:24

1 Answer 1


I tried to recreate your issue. Here are few possible reasons:

  1. You can't bind a VF page with standard Controller to a List Button. Because list button passes a list of selected records when clicked, so the standard functionality would expect the VF page to catch those records in a StandardSetController(reason why your page works with StandardSetController).

  2. Alternatively, keep your page with StandardController and you can use a URL in action of the list view button, like this- URLFOR('apex/YourPageName');

Like this

enter image description here

Part 2: To have your contactId prepopulated, you can modify your extension constructor like this.

public MyExtension(ApexPages.StandardController std){
String cId = ApexPages.currentPage().getParameters().get('contactid');
DetailContact__c dCon = (DetailContact__c)std.getRecord();
dCon.ContactId = cId;
  • Thanks, I tried using point 2, but since the Contact Id is not available anymore, I used : {!URLFOR('/apex/PageName?contactid=Contact.Id')}. However, Contact.Id is not repaced by the Id, and remains as is...
    – yassine
    Commented Nov 18, 2015 at 15:34
  • I have updated my answer with part 2 Commented Nov 18, 2015 at 16:54
  • 1
    Also, you should keep Contact.Id outside quotes in URLFOR. Like this - {!URLFOR('/apex/PageName?contactid='+Contact.Id)} Commented Nov 18, 2015 at 16:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .