I was working on an app the other day and had written a custom screen allowing the user to add/edit multiple records on the same page. So in the process I wrote a Visualforce page that Overrides the standard New and Edit functions and redirects the user to this new screen. Here's my code that I thought should have worked perfectly.

<apex:page standardController=”MyCustomObject__c”  
  action=”{!URLFOR($Page.AddEditMultipleRecords,null,
  [id=MyCustomObject__c.SomeRelatedObject__c])}”/>

The code above worked great for the New function but I was receiving the following error for the Edit function:

SObject row was retrieved via SOQL without querying the requested field: MyCustomObject__c.SomeRelatedObject__c

This is actually a well-known "problem" when using a standard controller. The standard controller automatically constructs your SOQL query for you based on the fields that are referenced in your page. So simply including the field on the page, fixes the error.

<apex:page standardController=”MyCustomObject__c”  
  action=”{!URLFOR($Page.AddEditMultipleRecords,null,
  [id=MyCustomObject__c.SomeRelatedObject__c])}”>
  {!MyCustomObject__c.SomeRelatedObject__c}
</apex:page>