I receive the following error:

SObject row was retrieved via SOQL without querying the requested field: Installation__c.Name 

Controller extension on custom object:

public class CrewWorkDetailController{

    public final Installation__c installation {get; private set;}

    public CrewWorkDetailController(ApexPages.StandardController stdController)
        this.installation = (Installation__c) stdController.getRecord() ;


<apex:page standardController="Installation__c" extensions="CrewWorkDetailController">

This is based on this example. Any ideas?

I tried renaming my variable and still does not work.

  • Try calling your variable something besides installation.
    – greenstork
    Commented Jun 12, 2014 at 15:59
  • I tried renaming my variable and still does not work.
    – d0001
    Commented Jun 12, 2014 at 16:08
  • 1
    How are you testing this page that it's not working. Have you overrode the standard New or View for your custom object with your extension. A controller extension relies on a standard object controller to be passed into it. Just viewing an apex page for an extension could also lead to your error.
    – greenstork
    Commented Jun 12, 2014 at 16:17
  • @greenstork The code I put in the question is all I have. I clicked preview and appended id of installation to url. The answer provided by sfdcfox seems to be right. Thanks for your help.
    – d0001
    Commented Jun 12, 2014 at 16:25

1 Answer 1


The only fields that are queried by default are the fields that are explicitly bound to the main standard controller during the page's construction (before the constructor of your extension is called).

You have two choices here:

1) You can use StandardController.reset() and StandardController.addFields() to add Name as a field to query.

2) You can bind directly the standard controller's record by using the name of the object:

<apex:page standardController="Installation__c" extensions="CrewWorkDetailController">

You must log in to answer this question.

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