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
Shekhar 13Shekhar 13 

Records not getting created in Account & Opp object in Visualforce page

Helo All ,
Please note I am using standard controller for account object  in VF page and the code gets saved means there is no error , but when I enter the values in the fields the record is not getting inserted , meaning I am not able to create account record . Even I have tried with opportunity object   also Iam not able to create opp record.

Kindly advice how this problem can be solved .


 
SwethaSwetha (Salesforce Developers) 
HI Shekar,
Can you share your code snippet?
Shekhar 13Shekhar 13
Hello Swetha,

Please check the below code

<apex:page standardController="Account">
<apex:form >

<apex:pageBlock title="My Content " mode="edit">

<apex:pageBlockButtons >
<apex:commandButton action="{!save}" value="Save "/>
</apex:pageBlockButtons>

<apex:pageBlockSection title="My Content Section" columns="2">

<apex:inputField value="{!account.name}"/>
<apex:inputField value="{!account.site}"/>
<apex:inputField value="{!account.type}"/>
<apex:inputField value="{!account.accountnumber}"/>


</apex:pageBlockSection>

</apex:pageBlock>


</apex:form>


</apex:page>
Maharajan CMaharajan C
Hi Shekhar,

I tried your code in my org and it's working fine. I think you are recieving some backend exceptions from validation rule or apex trigger.

Add the <apex:pageMessages/>  tag in your VF page so it will display the error in UI.
 
<apex:page standardController="Account">
    <apex:form >
        <apex:pageBlock title="My Content " mode="edit">
            
            <apex:pageMessages/>
            <apex:pageBlockButtons>
                
                <apex:commandButton action="{!save}" value="Save "/>
            </apex:pageBlockButtons>
            <apex:pageBlockSection title="My Content Section" columns="2">
                
                <apex:inputField value="{!account.name}"/>
                <apex:inputField value="{!account.site}"/>
                <apex:inputField value="{!account.type}"/>
                <apex:inputField value="{!account.accountnumber}"/>
                
            </apex:pageBlockSection>
        </apex:pageBlock>        
    </apex:form>    
</apex:page>

Thanks,
Maharajan.C
Shekhar 13Shekhar 13
Hi Maharajan,

It worked with the same code  actually I changed the browser .

Thanks
Shekhar