You need to sign in to do that
Don't have an account?

Hi By using controllers i had Created an Account In this page how to save the data from my account?
<apex:page controller="AccountExample1" showHeader="true" action="{!ActionToDo}">
<apex:form >
<apex:sectionHeader title="New Account" subtitle="Edit Account" />
<apex:pageBlock title="Account Edit" mode="Edit">
<apex:pageBlockSection title="Account Information">
<apex:outputField value="{!acc.ownerID}"/>
<apex:inputField value="{!acc.Rating}"/>
<apex:inputField value="{!acc.Name}"/>
<apex:inputField value="{!acc.Phone}"/>
<!--<apex:inputField value="{!acc.Parent}"/>-->
<apex:inputField value="{!acc.Fax}"/>
<apex:inputField value="{!acc.AccountNumber}"/>
<apex:inputField value="{!acc.Website}"/>
<apex:inputField value="{!acc.Site}"/>
<apex:inputField value="{!acc.TickerSymbol}"/>
<apex:inputfield value="{!acc.Type}"/>
<apex:inputField value="{!acc.OwnerShip}"/>
<apex:inputField value="{!acc.Industry}"/>
<apex:inputfield value="{!acc.NumberOfEmployees}"/>
<apex:inputfield value="{!acc.AnnualRevenue}"/>
<apex:inputField value="{!acc.sic}"/>
<apex:inputField value="{!acc.Account_Email__c}" />
<apex:inputField value="{!acc.Count_Contacts__c}"/>
</apex:pageBlockSection>
<apex:pageBlockSection title="Account Information" >
<apex:inputTextarea value="{!acc.BillingStreet}"/>
<apex:inputTextarea value="{!acc.ShippingStreet}"/>
<apex:inputField value="{!acc.BillingCity}"/>
<apex:inputField value="{!acc.ShippingCity}"/>
<apex:inputfield value="{!acc.BillingState}"/>
<apex:inputField value="{!acc.ShippingState}"/>
<!--<apex:inputField value="{!acc.BillingZip}"/>-->
<!--<apex:inputField value="{!acc.ShippingZip}"/>-->
</apex:pageBlockSection>
<apex:pageBlockSection title="Account Information">
<apex:inputfield value="{!acc.CustomerPriority__c}"/>
<apex:inputField value="{!acc.SLA__c}"/>
<apex:inputField value="{!acc.SLAExpirationDate__c}"/>
<apex:inputField value="{!acc.SLASerialNumber__c}"/>
<apex:inputField value="{!acc.NumberofLocations__c}"/>
<apex:inputField value="{!acc.UpsellOpportunity__c}"/>
<apex:inputField value="{!acc.Active__c}"/>
</apex:pageBlockSection>
<apex:pageBlockSection title="Description Information">
<apex:inputtextarea value="{!acc.Active__c}"/ >
</apex:pageBlockSection>
<apex:pageBlockButtons >
<apex:commandButton value="Save" action="{!Save}" />
</apex:pageBlockButtons>
</apex:pageBlock>
</apex:form>
</apex:page>
public class AccountExample1
{
public void Save() {
//acc = new Account();
insert acc;
}
public AccountExample1()
{
//acclist = [Select * from Account];
}
public Account acc{set;get;}
//public List<Account> acclist{set;get;}
public void ActionToDo()
{
}
}
Insead of 'insert acc' use:
All Answers
Hi PuranKishore,
You don't need to create a controller to save account. You can use standard controller as account.
This should save the account information entered. Please note that Field OwnerId is not writeable.
If you still wanna use controller. You can do something like this :
I am in Training so i want to know the apex class code is to practice it
Which u had said is i know the standard controller method but i want to know in controller how should we write it
public class AccountExample1
{
public void Save() {
insert acc;
}
public AccountExample1()
{
acc = new Account();
//acclist = [Select * from Account];
}
public Account acc{set;get;}
//public List<Account> acclist{set;get;}
public void ActionToDo()
{
}
}
Insead of 'insert acc' use: