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
Anuj Thakur 4Anuj Thakur 4 

Account is not created using VF page

Hi
I have created a VF page. I am trying to create a new Account with the help of my VF page. its running successfully but not saving the data i salesforce.
after entering the values in input text box and saving, I checked but account is not created. 
caould someone help meon this. why Account is not created.   
This is my VF page:
<apex:page standardController="Account">
<apex:form >
Name: <apex:inputText value="{!account.Name}"/><br/>

Phone:<apex:inputText value="{!account.Phone}"/><br/>
<apex:commandButton value="Create New account" action="{!Save}"/>
</apex:form>

</apex:page>
Thanks,
Anuj      
Best Answer chosen by Anuj Thakur 4
Dushyant SonwarDushyant Sonwar
Hi Anuj,

1)Try adding the apex:pagemessages , to find if there is any error.
<apex:page standardController="Account">
<apex:form >
<apex:pagemessages/>
Name: <apex:inputText value="{!account.Name}"/><br/>

Phone:<apex:inputText value="{!account.Phone}"/><br/>
<apex:commandButton value="Create New account" action="{!Save}"/>
</apex:form>

</apex:page>

2) Run developer console and check the count of records of account before and after clicking the save button if there is increase in number , then your account has been created.  If not , then need to check the debug logs as mentioned by above

Hope this helps.

All Answers

Manj_SFDCManj_SFDC
Please check debug logs and any validation rules or Mandatory fields on Account
Manj_SFDCManj_SFDC
You can refer this https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_controller_std_actions.htm
please mark the question  as  solved If this helps you good luck
Anuj Thakur 4Anuj Thakur 4

There is only one required field that is Name. I am using standard controller Account. I have checked the link you have provided, in that they have used <apex:inputField> buut I am using <apex:inputText> but I think this should not be the issue. i am not getting any error also so cant track.

Manj_SFDCManj_SFDC
Try using input field instead of input text 
Manj_SFDCManj_SFDC
INput text needs custom code to map it to SF field
Dushyant SonwarDushyant Sonwar
Hi Anuj,

1)Try adding the apex:pagemessages , to find if there is any error.
<apex:page standardController="Account">
<apex:form >
<apex:pagemessages/>
Name: <apex:inputText value="{!account.Name}"/><br/>

Phone:<apex:inputText value="{!account.Phone}"/><br/>
<apex:commandButton value="Create New account" action="{!Save}"/>
</apex:form>

</apex:page>

2) Run developer console and check the count of records of account before and after clicking the save button if there is increase in number , then your account has been created.  If not , then need to check the debug logs as mentioned by above

Hope this helps.
This was selected as the best answer
mukesh guptamukesh gupta
Hi Anuj,

I have tested your code that's was perfect, Please use:
<apex:page standardController="Account">
<apex:form >
Name: <apex:inputText value="{!account.Name}"/><br/>

Phone:<apex:inputText value="{!account.Phone}"/><br/>
<apex:commandButton value="Create New account" action="{!Save}"/>
</apex:form>

</apex:page>
Kindly mark my solution as the best answer if it helps you.

Thanks
Mukesh



 
Anuj Thakur 4Anuj Thakur 4
HI All,

Thanks for your help!!
I added <apex:pagemessages/> in page. and got the validation error on page. 
It is runnnig successfully now. 
Thanks Dushyant :)

Regards,
Anuj