Search code examples
salesforceapexvisualforce

Visualforce page throwing "Unable to Access Page" error in Salesforce


I created a Visualforce page in Salesforce to replace the "New" form for the Opportunity standard object. The code is:

<apex:page standardController="Opportunity" lightningStyleSheets="true">
    <apex:sectionheader title="Opportunity" subtitle="New"></apex:sectionheader>
    <apex:form>
            <apex:pageblock title="" mode="edit">
                <apex:pageMessages/>
                <apex:pageblockbuttons location="top">
                    <apex:commandbutton value="Save" action="{!create}"></apex:commandbutton>
                    <apex:commandButton action="{!cancel}" value="Cancel" immediate="true"/>
                </apex:pageblockbuttons>
                <apex:pageblocksection title="General Information">
                    <apex:inputfield value="{!Opportunity.Name}"/>
                </apex:pageblocksection>
            </apex:pageblock>
        </apex:form>
</apex:page>

The page renders fine:

Visualforce code rendered page

However, I get the "Unable to Access Page" error upon submission which states: "You are missing information needed by the page you have attempted to access. If you believe this is an error, please refresh your screen. If the error persists, please report it to our Customer Support team and provide the URL of the page you were requesting as well as any other related information."

I checked the Developer Console for clues. While I do see the submission in the logs, all it indicates is success without offering any meaningful clues to investigate further.

Developer Console log

I also checked my profile to see if the Visualforce page is accessible, and it is.

What else can I look into?


Solution

  • There's no standard controller action called create (https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_pages_standardcontroller.htm#apex_ApexPages_StandardController_methods).

    You want to use standard save or plug your own Apex class (probably as extension) and define create there?