You need to sign in to do that
Don't have an account?
bzain9
Creating VF page to execute when "New Account" is clicked on the Account Tab
I am looking to create a VF page exactly same of the Account List page just without the "New Button". How would I go about creating this? Sample code would be great!
Here is my first try at it!
<apex:page standardController="Account">
<apex:form >
<apex:pageBlock title="Account Details">
<apex:pageBlockButtons >
<apex:commandButton value="Save" action="{!save}"/>
</apex:pageBlockButtons>
<apex:pageBlockSection >
<apex:inputField value="{!Account.Name}"/>
<apex:inputField value="{!Account.AccountNumber}"/>
<apex:inputField value="{!Account.Type}"/>
<apex:inputField value="{!Account.NumberOfEmployees}"/>
<apex:inputField value="{!Account.Industry}"/>
<apex:inputField value="{!Account.Phone}"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
Here is my first try at it!
<apex:page standardController="Account">
<apex:form >
<apex:pageBlock title="Account Details">
<apex:pageBlockButtons >
<apex:commandButton value="Save" action="{!save}"/>
</apex:pageBlockButtons>
<apex:pageBlockSection >
<apex:inputField value="{!Account.Name}"/>
<apex:inputField value="{!Account.AccountNumber}"/>
<apex:inputField value="{!Account.Type}"/>
<apex:inputField value="{!Account.NumberOfEmployees}"/>
<apex:inputField value="{!Account.Industry}"/>
<apex:inputField value="{!Account.Phone}"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
If you want to use at new button or any delivered object button you need to extend the the existing controller then you will be able to edit the new buttona and use this visualforce page .
a) Create visual force page like you mentioned and give some name
You can try this
<apex:page standardController="Account" extensions="CreateAccount" >
<apex:form >
<apex:pageBlock title="Account Details">
<apex:pageBlockButtons >
<apex:commandButton value="Save" action="{!SavingTheData}"/>
</apex:pageBlockButtons>
<apex:pageBlockSection >
<apex:inputField value="{!Account.Name}"/>
<apex:inputField value="{!Account.AccountNumber}"/>
<apex:inputField value="{!Account.Type}"/>
<apex:inputField value="{!Account.NumberOfEmployees}"/>
<apex:inputField value="{!Account.Industry}"/>
<apex:inputField value="{!Account.Phone}"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page
b) Use Controller extension
public class CreateAccount {
public Account acc {get ;set;}
public CreateAccount (ApexPages.StandardController stdController)
{
acc = (Account)stdController.getRecord();
}
Public PageReference SavingTheData()
{
insert acc;
return new PageReference('/' + acc.id);
}
}
c) edit the new buttona and Use newly created visualforce page