+ Start a Discussion
sg_7sg_7 

controller for visualforce page

Hi!

 

I want controller for below code.please help me.

 

<apex:page controller="mycustomcontroller">
    <apex:form >
        <apex:sectionHeader title="New Account" subtitle="Account Edit"/>
        <apex:pageBlock helpUrl="https://help.salesforce.com/htviewhelpdoc?err=1&id=account_edit.htm&siteLang=en_US"
                                                          helpTitle="Help for this Page" title="Account Edit" >
            <apex:pageBlockButtons location="bottom">
                <apex:commandButton action="{!save}" value="Save"/>
                <apex:commandButton action="{!Saveandnew}" value="Save & New" id="saveAndNew"/>
                <apex:commandButton action="{!cancel}" value="cancel"/>
            </apex:pageBlockButtons>
            <apex:pageBlockSection title="Account information"  >
            
               
                <apex:inputField value="{!account.name}" />
                <apex:inputField value="{!Account.rating}"/>
                <apex:inputField value="{!account.parentid}"/>
                <apex:inputField value="{!Account.Phone}"/>
                <apex:inputField value="{!Account.AccountNumber}"/>
                <apex:inputField value="{!Account.Fax}"/>
                <apex:inputField value="{!Account.Site}"/>
                <apex:inputField value="{!Account.Website}"/>
                <apex:inputField value="{!Account.Type}"/>
                <apex:inputField value="{!Account.Ownership}"/>
                <apex:inputField value="{!Account.Industry}"/>
                <apex:inputField value="{!Account.NumberOfEmployees}"/>
                <apex:inputField value="{!Account.AnnualRevenue}"/>
                <apex:inputField value="{!Account.Sic}"/>
                
            </apex:pageBlockSection>   
             
            <apex:pageBlockSection title="Address Information" onclick="copy Billing Address to Shipping Address" >
                <A HREF="#" onClick="return copyAddress();">Copy  Mailing Address to Residence Address</A><br></br>
                <apex:inputField value="{!Account.BillingStreet}"/>
                <apex:inputField value="{!Account.ShippingStreet}"/>
                <apex:inputField value="{!Account.Billingcity}"/>
                <apex:inputField value="{!Account.ShippingCity}"/>
                <apex:inputField value="{!Account.Billingstate}"/>
                <apex:inputField value="{!Account.Shippingstate}"/>
                <apex:inputField value="{!Account.Billingpostalcode}"/>
                <apex:inputField value="{!Account.Shippingpostalcode}"/>
                <apex:inputField value="{!Account.Billingcountry}"/>
                <apex:inputField value="{!Account.Shippingcountry}"/>
                
            </apex:pageBlockSection>
            <apex:pageBlockSection title="Additional Information">
                <apex:inputField value="{!Account.CustomerPriority__c}"/>
                <apex:inputField value="{!Account.SLA__c}"/>
                <apex:inputField value="{!Account.SLAExpirationDate__c}"/>
                <apex:inputField value="{!Account.SLASerialNumber__c}"/>
                <apex:inputField value="{!Account.NumberofLocations__c}"/>
                <apex:inputField value="{!Account.UpsellOpportunity__c}"/>
                <apex:inputField value="{!Account.Active__c}"/>
                
            </apex:pageBlockSection>
            
            <apex:pageBlockSection title="Description Information">
            <apex:inputField value="{!Account.Description}"/>
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>

Dhaval PanchalDhaval Panchal

You don't need to required controller for this page.

Just do (highlighted in red) below changes in your vf page

 

<apex:page standardController="Account">
    <apex:form >
        <apex:sectionHeader title="New Account" subtitle="Account Edit"/>
        <apex:pageBlock helpUrl="https://help.salesforce.com/htviewhelpdoc?err=1&id=account_edit.htm&siteLang=en_US"
                                                          helpTitle="Help for this Page" title="Account Edit" >
            <apex:pageBlockButtons>
                <apex:commandButton action="{!save}" value="Save"/>
                <apex:commandButton action="{!quicksave}" oncomplete="return saveandnew();" value="Save & New" id="saveAndNew"/>
                <apex:commandButton action="{!cancel}" value="cancel"/>
            </apex:pageBlockButtons>
            <apex:pageBlockSection title="Account information"  >
            
               
                <apex:inputField value="{!account.name}" />
                <apex:inputField value="{!Account.rating}"/>
                <apex:inputField value="{!account.parentid}"/>
                <apex:inputField value="{!Account.Phone}"/>
                <apex:inputField value="{!Account.AccountNumber}"/>
                <apex:inputField value="{!Account.Fax}"/>
                <apex:inputField value="{!Account.Site}"/>
                <apex:inputField value="{!Account.Website}"/>
                <apex:inputField value="{!Account.Type}"/>
                <apex:inputField value="{!Account.Ownership}"/>
                <apex:inputField value="{!Account.Industry}"/>
                <apex:inputField value="{!Account.NumberOfEmployees}"/>
                <apex:inputField value="{!Account.AnnualRevenue}"/>
                <apex:inputField value="{!Account.Sic}"/>
                
            </apex:pageBlockSection>   
             
            <apex:pageBlockSection title="Address Information" onclick="copy Billing Address to Shipping Address" >
                <A HREF="#" onClick="return copyAddress();">Copy  Mailing Address to Residence Address</A><br></br>
                <apex:inputField value="{!Account.BillingStreet}"/>
                <apex:inputField value="{!Account.ShippingStreet}"/>
                <apex:inputField value="{!Account.Billingcity}"/>
                <apex:inputField value="{!Account.ShippingCity}"/>
                <apex:inputField value="{!Account.Billingstate}"/>
                <apex:inputField value="{!Account.Shippingstate}"/>
                <apex:inputField value="{!Account.Billingpostalcode}"/>
                <apex:inputField value="{!Account.Shippingpostalcode}"/>
                <apex:inputField value="{!Account.Billingcountry}"/>
                <apex:inputField value="{!Account.Shippingcountry}"/>
                
            </apex:pageBlockSection>
            <apex:pageBlockSection title="Additional Information">
                <apex:inputField value="{!Account.CustomerPriority__c}"/>
                <apex:inputField value="{!Account.SLA__c}"/>
                <apex:inputField value="{!Account.SLAExpirationDate__c}"/>
                <apex:inputField value="{!Account.SLASerialNumber__c}"/>
                <apex:inputField value="{!Account.NumberofLocations__c}"/>
                <apex:inputField value="{!Account.UpsellOpportunity__c}"/>
                <apex:inputField value="{!Account.Active__c}"/>
                
            </apex:pageBlockSection>
            
            <apex:pageBlockSection title="Description Information">
            <apex:inputField value="{!Account.Description}"/>
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
    <script>        function saveandnew(){
//I have used name "AddNewAccount for this vf page, you have to change as per your name window.location = location.protocol+'//'+location.host+'/apex/AddNewAccount'; return true; }
</script> </apex:page>

 

shikher goelshikher goel

Hi,

 

Here is a one more suggestion for your VF page. Since you have to display the fields of standard controller.You can use Field Sets out of box feature of salesforce.

 

For information in fieldset ,you can go through this link.

 

http://www.salesforce.com/us/developer/docs/pages/Content/pages_dynamic_vf_field_sets.htm

 

Thanks,

Shikher Gel

sg_7sg_7

Thanks Dhaval Panchal

 

It's Working,But I have Development Mode Footer in my page,When I was click "Save & new" button one more Development mode footer open, may I know the region..

 

 

 

 

Thanks,

Ramesh

Arunkumar.RArunkumar.R

Hi,

 

To remove Developement mode from your visualforce page just uncheck Development Mode in USER.

 

Just go to Manage Users--> Users--> Edit --> Uncheck Developement Mode.