+ Start a Discussion
SureshKolliSureshKolli 

ACCOUNT INSERTION PROBLEM

HI EVERY ONE ,

          I NEED TO INSERT A  ACCOUNT WHILE  LODING VF PAGE ,SO I HAVE WRITTEN SOME CODE BUT ITS GIVE ERROR PLZ FOLLOW THIS


<apex:page controller="InsertAccount"  action="{!insertAccount}">
<apex:form >
{!msg}
</apex:form>
</apex:page>

CLASS

public class InsertAccount
{
public string msg{get;set;}
public void insertAccount()
{
Account a=new Account();
a.Name='Sairamu';
a.AccountNumber='68348657279';
insert a;
msg='Account record successfully insertyd..';
}



ERROR MESSAGE:

Visualforce Error
Help for this Page

System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, createNewAccountOpportunity: execution of AfterInsert caused by: System.DmlException: Update failed. First exception on row 0; first error: MISSING_ARGUMENT, Id not specified in an update call: [] Trigger.createNewAccountOpportunity: line 15, column 1: []
Error is in expression '{!insertAccount}' in component <apex:page> in page accountinsert


SO CAN PLZ ANY ONE HELP OUT OF THIS???????????/
Developer99Developer99
@suresh ,

         your code is working finr for me.it is inserted successfully.
Sri549Sri549
Hello Suresh

I also tried the provided code from my side its working fine ,but see what happend in your side is parallely a trigger saying "createNewAccountOpportunity" is firing and breaking the insertion,so you need to write a logic for inserting an account in such a way like it supports the condition as like in trigger.

If your are facing same problem please let me know..

Hit Kudos if this provides you with useful information and if this is what you where looking for then please mark it as a solution for other benefits.

Thank You,
Srinivas
SFDC Certified Developer