I'm new to salesforce development, and I want to overwrite the New action button for my custom object. Here is my VFP code.

<apex:page standardcontroller="Document__c">
    <apex:sectionHeader title="New Document" subtitle="Document Creation Form"/>
    <apex:form >
        <apex:pageBlock title="Document Information">
                <apex:inputField label="Document Name" value="{!Document__c.Name}" required="true"/>
            <apex:pageBlockButtons >
                <apex:commandButton action="{!save}" value="Save"/>
                <apex:commandButton action="{!cancel}" value="Cancel"/>

I really don't know how to start this, but I want the same pop-up window like the standard button. How can i do this?

I guess I need an apex class for that to save, but firstly I want to make the same like the standard new button, but with the fields which I choose.

  • one thought - tech-vision.us/…
    – cropredy
    Commented Mar 23, 2023 at 15:51
  • I just wan to exclude few fields when I click new,but then I want to display them when clicking on the record. This link create a new layout, I dont’t need new.
    – Csabikaaaa
    Commented Mar 23, 2023 at 16:07

1 Answer 1


So, there's an alternative that doesn't require code: create a new "new" action, and put it where you need it (next to or in place of the old "new" button). This does require some knowledge of how to get around in Salesforce, though.

Global action creation screen Local action creation screen

Step one is to create the action. Pick your object (I'm using Case as the example here), pick a label, add a description so you remember what it's for, and hit "save". You can do this either globally or locally; local is better in most circumstances, such as when you're fine with the resulting button just being on the case's list (or detail) view, rather than trying to put it on an opportunity or something, or when you want to prefill fields based on context.

Field choices

Step two is to pick which fields you want visible on your creation screen. Given your stated requirements, this is definitely not "all of them". Picking a field is a matter of dragging it from the top section down onto the layout.

List view layout Last step is to put the new action where you want it; screenshot displays where to put it if you want it replacing the list view "new" button.


You must log in to answer this question.

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