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
Hareesh SankaHareesh Sanka 

Using Account object as reference i have created the custom fields using visual force page which are available in account object. What are the next steps if i want to save the records to custom object?

GovindarajGovindaraj
Assuming that you want to save the account fields in custom object.

VF page:
------------
<apex:page standardcontroller="Account" extensions="saveRecord" >
    <apex:form>
        <apex:pageblock>
            <apex:inputText value="{!accountName}" id="accountName" />
            <apex:inputText value="{!accountPhone}" id="accountPhone" />
            <apex:commandbutton value="Save" action="{!Save}" />
        </apex:pageblock>
    </apex:form>
</apex:page>

Apex class:
---------------
Public class saveRecord {
    Public string accountName {get;set;}
    Public string accountPhone {get;set;}

    Public saveRecord(ApexPages.StandardController controller) {
        CustomObject__c obj = new CustomObject__c();
        obj.fieldName__c = accountName;
        obj.fieldPhone__c = accountPhone;
        insert obj;
    }
}
Raj VakatiRaj Vakati
Use this code
 
<apex:page standardcontroller="Account" extensions="saveRecord" >
    <apex:form>
        <apex:pageblock>
            <apex:inputText value="{!accountName}" id="accountName" />
            <apex:inputText value="{!accountPhone}" id="accountPhone" />
            <apex:commandbutton value="Save" action="{!Save}" />
        </apex:pageblock>
    </apex:form>
</apex:page>
 
Public class saveRecord {
    Public string accountName {get;set;}
    Public string accountPhone {get;set;}

    Public saveRecord(ApexPages.StandardController controller) {
        accountName = 'Demo';
         accountPhone='12312323';
        //insert obj;
    }
	
	Public PageReference save() {
        CustomObject__c obj = new CustomObject__c();
        obj.fieldName__c = accountName;
        obj.fieldPhone__c = accountPhone;
        insert obj;
		return null;
    }
}

 
Hareesh SankaHareesh Sanka
Thanks Raj for your answer.

Actually i have created all the fields using VF page only without refering Standard controller as Account . Here is the code.

<apex:page >
    <apex:sectionHeader title="AccountEdit" subtitle="New Account" help="/apex/calculator"/>
    <apex:form id="pb">
        <apex:pageBlock title="AccountEdit" tabStyle="Account">
            <apex:pageBlockButtons >
                <apex:commandButton value="Save" rerender="pb"/>
                <apex:commandButton value="Save & New" rerender="pb" />
                <apex:commandButton value="Cancel" rerender="pb"/>
            </apex:pageBlockButtons>
            <apex:pageBlockSection title="Account Information" collapsible="false" >
                <apex:pageBlockSectionItem >
                    <apex:outputLabel value="Account Owner"/>
                    <apex:inputText />
                </apex:pageBlockSectionItem>
                <apex:pageBlockSectionItem >
                    <apex:outputLabel value="Rating"/>
                    <apex:selectList size="1">
                        <apex:selectOption itemLabel="None" itemValue="none"/>
                        <apex:selectOption itemLabel="Hot" itemValue="hot"/>
                        <apex:selectOption itemLabel="Warm" itemValue="warm"/>
                        <apex:selectOption itemLabel="Cold" itemValue="cold"/>
                    </apex:selectList>
                </apex:pageBlockSectionItem>
                <apex:pageBlockSectionItem >
                    <apex:outputLabel value="Account Name"/>
                    <apex:inputText />
                </apex:pageBlockSectionItem>
                <apex:pageBlockSectionItem >
                    <apex:outputLabel value="Phone"/>
                    <apex:inputText />
                </apex:pageBlockSectionItem>
                 <apex:pageBlockSectionItem >
                    <apex:outputLabel value="Parent Account"/>
                    <apex:inputText />
                </apex:pageBlockSectionItem>
                 <apex:pageBlockSectionItem >
                    <apex:outputLabel value="Fax"/>
                    <apex:inputText />
                </apex:pageBlockSectionItem>
                 <apex:pageBlockSectionItem >
                    <apex:outputLabel value="Account Number"/>
                    <apex:inputText />
                </apex:pageBlockSectionItem>
                 <apex:pageBlockSectionItem >
                    <apex:outputLabel value="Website"/>
                    <apex:inputText />
                </apex:pageBlockSectionItem>
                 <apex:pageBlockSectionItem >
                    <apex:outputLabel value="Account site"/>
                    <apex:inputText />
                </apex:pageBlockSectionItem>
                 <apex:pageBlockSectionItem >
                    <apex:outputLabel value="Ticker Symbol"/>
                    <apex:inputText />
                </apex:pageBlockSectionItem>
                <apex:pageBlockSectionItem >
                    <apex:outputLabel value="Type"/>
                    <apex:selectList size="1">
                        <apex:selectOption itemLabel="None" itemValue="none"/>
                        <apex:selectOption itemLabel="Prospect" itemValue="prospect"/>
                        <apex:selectOption itemLabel="Customer-Direct" itemValue="customerDirect"/>
                        <apex:selectOption itemLabel="Customer-Channel" itemValue="customerChannel"/>
                    </apex:selectList>
                </apex:pageBlockSectionItem>
                <apex:pageBlockSectionItem >
                    <apex:outputLabel value="Ownership"/>
                    <apex:selectList size="1">
                        <apex:selectOption itemLabel="None" itemValue="none"/>
                        <apex:selectOption itemLabel="Public" itemValue="public"/>
                        <apex:selectOption itemLabel="Private" itemValue="private"/>
                        <apex:selectOption itemLabel="Other" itemValue="other"/>
                    </apex:selectList>
                </apex:pageBlockSectionItem>
                <apex:pageBlockSectionItem >
                    <apex:outputLabel value="Industry"/>
                    <apex:selectList size="1">
                        <apex:selectOption itemLabel="None" itemValue="none"/>
                        <apex:selectOption itemLabel="Agriculture" itemValue="agriculture"/>
                        <apex:selectOption itemLabel="Banking" itemValue="banking"/>
                        <apex:selectOption itemLabel="Education" itemValue="education"/>
                    </apex:selectList>
                </apex:pageBlockSectionItem>
                <apex:pageBlockSectionItem >
                    <apex:outputLabel value="Employees"/>
                    <apex:inputText />
                </apex:pageBlockSectionItem>
                <apex:pageBlockSectionItem >
                    <apex:outputLabel value="Annual Revenue"/>
                    <apex:inputText />
                </apex:pageBlockSectionItem>
                <apex:pageBlockSectionItem >
                    <apex:outputLabel value="SIC Code"/>
                    <apex:inputText />
                </apex:pageBlockSectionItem>
            </apex:pageBlockSection>
            <apex:pageBlockSection title="Address Information" collapsible="false" >
                <apex:pageBlockSectionItem >
                    <apex:outputLabel value="Billing Street"/>
                    <apex:inputTextarea />
                </apex:pageBlockSectionItem>
                <apex:pageBlockSectionItem >
                    <apex:outputLabel value="Shipping Street"/>
                    <apex:inputTextarea />
                </apex:pageBlockSectionItem>
                <apex:pageBlockSectionItem >
                    <apex:outputLabel value="Billing City"/>
                    <apex:inputText />
                </apex:pageBlockSectionItem>
                <apex:pageBlockSectionItem >
                    <apex:outputLabel value="Shipping City"/>
                    <apex:inputText />
                </apex:pageBlockSectionItem>
                 <apex:pageBlockSectionItem >
                    <apex:outputLabel value="Billing State/Province"/>
                    <apex:inputText />
                </apex:pageBlockSectionItem>
                 <apex:pageBlockSectionItem >
                    <apex:outputLabel value="Shipping State/Province"/>
                    <apex:inputText />
                </apex:pageBlockSectionItem>
                 <apex:pageBlockSectionItem >
                    <apex:outputLabel value="Billing Zip/Postal Code"/>
                    <apex:inputText />
                </apex:pageBlockSectionItem>
                 <apex:pageBlockSectionItem >
                    <apex:outputLabel value="Shipping Zip/Postal Code"/>
                    <apex:inputText />
                </apex:pageBlockSectionItem>
                <apex:pageBlockSectionItem >
                    <apex:outputLabel value="Billing Country"/>
                    <apex:inputText />
                </apex:pageBlockSectionItem>
                <apex:pageBlockSectionItem >
                    <apex:outputLabel value="Shipping Country"/>
                    <apex:inputText />
                </apex:pageBlockSectionItem>
            </apex:pageBlockSection>
            <apex:pageBlockSection title="Additional Information" collapsible="false">
                <apex:pageBlockSectionItem >
                    <apex:outputLabel value="Customer Priority"/>
                    <apex:selectList size="1">
                        <apex:selectOption itemLabel="None" itemValue="none"/>
                        <apex:selectOption itemLabel="High" itemValue="high"/>
                        <apex:selectOption itemLabel="Low" itemValue="low"/>
                        <apex:selectOption itemLabel="Medium" itemValue="medium"/>
                    </apex:selectList>
                </apex:pageBlockSectionItem>
                <apex:pageBlockSectionItem >
                    <apex:outputLabel value="SLA"/>
                    <apex:selectList size="1">
                        <apex:selectOption itemLabel="None" itemValue="none"/>
                        <apex:selectOption itemLabel="Gold" itemValue="gold"/>
                        <apex:selectOption itemLabel="Silver" itemValue="silver"/>
                        <apex:selectOption itemLabel="Bronze" itemValue="bronze"/>
                    </apex:selectList>
                </apex:pageBlockSectionItem>
                <apex:pageBlockSectionItem >
                    <apex:outputLabel value="SLA Expiration Date"/>
                    <apex:inputText />
                </apex:pageBlockSectionItem>
                <apex:pageBlockSectionItem >
                    <apex:outputLabel value="SLA Serial Number"/>
                    <apex:inputText />
                </apex:pageBlockSectionItem>
                <apex:pageBlockSectionItem >
                    <apex:outputLabel value="Number of Locations"/>
                    <apex:inputText />
                </apex:pageBlockSectionItem>
                <apex:pageBlockSectionItem >
                    <apex:outputLabel value="Upsell Opportunity"/>
                    <apex:selectList size="1">
                        <apex:selectOption itemLabel="None" itemValue="none"/>
                        <apex:selectOption itemLabel="Maybe" itemValue="maybe"/>
                        <apex:selectOption itemLabel="No" itemValue="no"/>
                        <apex:selectOption itemLabel="Yes" itemValue="yes"/>
                    </apex:selectList>
                </apex:pageBlockSectionItem>
                <apex:pageBlockSectionItem >
                    <apex:outputLabel value="Active"/>
                    <apex:selectList size="1">
                        <apex:selectOption itemLabel="None" itemValue="none"/>
                        <apex:selectOption itemLabel="Yes" itemValue="yes"/>
                        <apex:selectOption itemLabel="No" itemValue="no"/>
                    </apex:selectList>
                </apex:pageBlockSectionItem>
            </apex:pageBlockSection>
            <apex:pageBlockSection title="Description Information" collapsible="false">
                <apex:pageBlockSectionItem >
                    <apex:outputLabel value="Description"/>
                    <apex:inputTextarea />
                </apex:pageBlockSectionItem>
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>