• PSS_IT
  • NEWBIE
  • 0 Points
  • Member since 2011

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 1
    Replies

Hi,

 

I'd like to make a trigger that would delete a lead record when the lead first name and last name are the same.  Here is what I have so far and I'm getting error message:

 

Apex trigger Test1 caused an unexpected exception, contact your administrator: Test1: execution of BeforeInsert caused by: System.SObjectException: DML statment cannot operate on trigger.new or trigger.old: Trigger.Test1: line 5, column 6

 

What do I need to change?

 

trigger Test1 on Lead (before insert) {
   for(Lead a: Trigger.new){
 if (a.firstname == a.lastname)
 try {
     delete a;
   } catch (DmlException e)
   {}
   }
  }

 

Thanks in advance!

  • April 19, 2011
  • Like
  • 0

How can you create an apex class for case object that would

 

- close current case

- clone current case by inserting new record

- change record type

 

 

  • April 12, 2011
  • Like
  • 0

Hi,

 

I'd like to make a trigger that would delete a lead record when the lead first name and last name are the same.  Here is what I have so far and I'm getting error message:

 

Apex trigger Test1 caused an unexpected exception, contact your administrator: Test1: execution of BeforeInsert caused by: System.SObjectException: DML statment cannot operate on trigger.new or trigger.old: Trigger.Test1: line 5, column 6

 

What do I need to change?

 

trigger Test1 on Lead (before insert) {
   for(Lead a: Trigger.new){
 if (a.firstname == a.lastname)
 try {
     delete a;
   } catch (DmlException e)
   {}
   }
  }

 

Thanks in advance!

  • April 19, 2011
  • Like
  • 0