• santusfdc1.3926196430109492E12
  • NEWBIE
  • 10 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 3
    Replies
Hi members ,

i have written a trigger on the oppportunity in the object if the stage is "closed won " i need to insert a record in the account.and i m getting the error and the error is (Error:Apex trigger opptrigger caused an unexpected exception, contact your administrator: opptrigger: execution of AfterUpdate caused by: System.DmlException: Upsert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [Account Name]: [Account Name]: Trigger.opptrigger: line 23, column 1)




trigger opptrigger on Opportunity (after insert,after update)
{
      //Create a list to hold all new records  
   List<Account> newRecords = new List<Account>();
  
    //Loop around all records in the trigger transaction 
    for(Opportunity theRecord : Trigger.new)
{
          //Evaluate the record against our critieria    
     if(theRecord.StageName == 'Closed Won')
{
              //The line below creates a new Account record and adds it to our list of new records. Add your field assigments (examples below). Make sure to assign all required fields.          
   Account newRecord = new Account();           
  //newRecord.Name = theRecord.name;        
     //newRecord.Description = 'My New Record';           
  newRecords.add(newRecord);       
   }   
  }     
//Insert the new records if any exist   
  if(newRecords.size() > 0)    
     upsert newRecords;
}
Hi members ,

i have written a trigger on the oppportunity in the object if the stage is "closed won " i need to insert a record in the account.and i m getting the error and the error is (Error:Apex trigger opptrigger caused an unexpected exception, contact your administrator: opptrigger: execution of AfterUpdate caused by: System.DmlException: Upsert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [Account Name]: [Account Name]: Trigger.opptrigger: line 23, column 1)




trigger opptrigger on Opportunity (after insert,after update)
{
      //Create a list to hold all new records  
   List<Account> newRecords = new List<Account>();
  
    //Loop around all records in the trigger transaction 
    for(Opportunity theRecord : Trigger.new)
{
          //Evaluate the record against our critieria    
     if(theRecord.StageName == 'Closed Won')
{
              //The line below creates a new Account record and adds it to our list of new records. Add your field assigments (examples below). Make sure to assign all required fields.          
   Account newRecord = new Account();           
  //newRecord.Name = theRecord.name;        
     //newRecord.Description = 'My New Record';           
  newRecords.add(newRecord);       
   }   
  }     
//Insert the new records if any exist   
  if(newRecords.size() > 0)    
     upsert newRecords;
}
HI i have a requirement.
i have 2 objects object A and object B object B is the master object and object A is child. on object B i need to create a custom button, onclick the custom button i need to popup a visualforce page we have fields along with save button . on entering the fields and on clicking the SAVE button the fields should get updated on the object A fields.

please let me know how to do it.. 


thanks in advance..
regards,
Santosh