I am attempting to override the "new" button that I see on the Opportunity List page with a Visual Force page. I intend to use the same page and same controller for the New and Edit buttons. The Edit functionality is working as expected. The "New" is throwing an error.

Recent Opportunity Screen When I click on the "New" button, I am getting the following message.

An internal server error has occurred
An error has occurred while processing your request. The salesforce.com support team has been notified of the problem. If you believe you have additional information that may be of help in reproducing or correcting the error, please contact Salesforce Support. Please indicate the URL of the page you were requesting, any error id shown on this page as well as any other related information. We apologize for the inconvenience. 

Thank you again for your patience and assistance. And thanks for using salesforce.com! 

Error ID: 630716990-2384169 (-509331411)

I am reading the Visual Force in Practice Guide and it has the following text.

This can also occur when the StandardController instance is passed into an Apex custom controller extension as a parameter on the class constructor. If the record is retrieved by use of the getRecord() method on the StandardController instance, and some Apex code attempts to reference a field not bound on the page, an exception will be thrown.

I have bound all the fields. For the sake of conciseness, I have reduced the number of fields that are being added and displayed on the page. It is a mix of standard fields and custom fields.

Here is the code for my ControllerExtension.

public with sharing class OppExtension 

    private final Opportunity opportunity;
    public Boolean showQuoteNowButton {get;set;}
    public class PageValidateException extends Exception{}

    // The extension constructor initializes the private member
    // variable mysObject by using the getRecord method from the standard
    // controller.
    public OppExtension(ApexPages.StandardController stdController) 
        if( !Test.isRunningTest() )
           stdController.addFields(new List<string>{'RecordType','StageName','AccountId','Name','CloseDate','Id','Contact__c','LeadSource'});
           this.opportunity = (Opportunity)stdController.getRecord();

        if(this.opportunity.Id == null)
            this.opportunity.RecordTypeId = '012700000005nffAAA';

            if(this.opportunity.X42Id__c == null){
                showQuoteNowButton = true;
                showQuoteNowButton = false;

Here is my Visual Force Page.

<apex:page standardController="Opportunity" extensions="OppExtension" showheader="true" sidebar="true">
<apex:pageMessages id="msgs" rendered="true" showDetail="true">                 
    <apex:sectionHeader title="Opportunity Edit" subtitle="{!Opportunity.name}"/>
    <apex:form >
        <apex:pageBlock title="Opportunity Edit" mode="edit">
            <apex:pageBlockButtons location="bottom">
                <apex:commandButton title="Quote now" value="Quote Now" action="{!save}" rendered="{!showQuoteNowButton}"/>
                <apex:commandButton value="Cancel" action="{!cancel}"/>
            <apex:pageBlockSection title="Naming convention: Party Name-Branch Name-Site Location-Project Description" columns="1">
                <apex:inputField value="{!Opportunity.Name}" required="true"/>
            <apex:pageBlockSection title="Opportunity Information" columns="2">
                <apex:inputField value="{!Opportunity.Floors__c}" required="true"/>
                <apex:inputField value="{!Opportunity.StageName}" required="true"/>             
                <apex:inputField value="{!Opportunity.AccountId}" required="true"/>
                <apex:inputField value="{!Opportunity.CloseDate}" required="true"/>             
                <apex:inputField value="{!Opportunity.Contact__c}" required="true"/>                
                <apex:inputField value="{!Opportunity.LeadSource}" required="true"/>
  • 1
    (a) Go contact support, because that error probably shouldn't be happening from what I can tell (or, if it is, it's related to one of your custom fields), and (b) you probably meant to add RecordTypeId in the addFields function, not RecordType. I thought that might causing the crash, but I wasn't able to get an Internal Server Error when I tried that.
    – sfdcfox
    Commented Apr 21, 2016 at 22:15
  • 1
    (1) check out developer.salesforce.com/blogs/engineering/2015/02/gack.html ; expect a long wait from premier support to help you (days of back and forth). My personal advice is to start ripping out stuff until you have something working again, then add back little bits until you gack again. (2) Also - hard-coded recordTypeIds - not best practice -- you can use Schema Describe methods to obtain; (3) why is the opportunity variable final?
    – cropredy
    Commented Apr 21, 2016 at 22:37
  • @sfdcfox I have already logged a case out with support.
    – abhi
    Commented Apr 22, 2016 at 12:40

1 Answer 1


With the help of my colleague, I have been able to narrow down this problem to a FORMULA that existed in the DEFAULT value for one of the fields on the page. I got rid of the formula from the default value and now my page renders as expected.

I am posting this as an answer in case someone else faces this problem.

You must log in to answer this question.

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