function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Dippan PatelDippan Patel 

Problem overriding a visualforce page

Hi Everyone, 

I want to override custom object new button with my visualforce page. After selecting the page to override on the custom object new button, I am getting the below error.  Error overriding visualforce page
Dippan PatelDippan Patel
User-added image
Dushyant SonwarDushyant Sonwar
Hi Dippan ,

You need to set standard controller = "yourcustomobjectapinamewhichyouwanttooverride" in Apex:page tag to override.
 
Dippan PatelDippan Patel
Hi Dushyant, 

I did that i am able to see my page in the override options but after clicking on save, I am having this error of custom validation 
Dippan PatelDippan Patel
My custom object name is:Contact_Additional_Address__c
I can override on my developer org but if I install the same thing on other org, custom validation error occurs. 

Here is my code sample: 
 
<apex:page standardController="Contact_Additional_Address__c" extensions="ContactAdditionalAddress"> 
...

</apex:form>
 
public ContactAdditionalAddress(ApexPages.StandardController controller){ 

public ContactAdditionalAddress(ApexPages.StandardController controller){}

//code logic 

}

 
Dushyant SonwarDushyant Sonwar
Is this vf page part of manage package? As you said that you are installing it. If yes, then you need to add the namespaceprefix to your standard controller ="namespaceprefix__customobject".
Dippan PatelDippan Patel
Yes, it is a part of managed package. Custom object is also the part of maanged package and i am able to override that one but if I create a custom object locally then override is not possible.  So basically i have two custom objects, one with the package and other created locally. Packaged custom object has namespaceprefix in apiname while the local one doesn't. 

namespaceprefix__customobject__c (available with the package) (able to override)
customobject__c (created locally) (error while overrriding) 

Standard controller is customobject__c