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
mdelgadomdelgado 

Getting Entity is Deleted error

Hello,

 

I am new to salesfoce.  I have a code snippet that is giving me an Entity is Deleted error exception.  Can someone tell me what is wrong with the code?

 

 

    Lead lead = trigger.new[0];
    List <Event> e1 = new List<Event>(); 
    
    if (trigger.isUpdate)
    {  
        e1 =[select id,subject from Event where Whoid =: lead.id AND Created_by_Trigger__c = true and IsRecurrence = false];

         delete e1;
    }


I modified the code to this, but exception also being thrown on delete


    Lead lead = trigger.new[0];
    Event evs1;
    List <Event> e1 = new List<Event>(); 
    
    if (trigger.isUpdate)
    {  
        e1 =[select id,subject from Event where Whoid =: lead.id AND Created_by_Trigger__c = true and IsRecurrence = false];

        for (integer i =0; i< e1.size();i++)
        {    
            evs1 = e1[i];
            
	    delete evs1;       	
        }
    }

 

thanks,

 

Mirko

UVUV

Change the event from "After Update" to "Before Update".

mdelgadomdelgado

Umesh,

 

Thanks for your reply.  I don't think that is the issue.  I have the following on my trigger

 

trigger ManageLeadTrigger on Lead (after insert, before update) {

 

Any other suggestions?  Or am I missing something?

 

thanks,

 

Mirko

UVUV

Are you trying to delete recurring events???

 

UVUV

I believe you are trying to delete recurring events..When you create a recurring event then one series gets created and multiple events gets created for that series.If you delete series, all events would be deleted automatically...

 

Consider the following when deleting a series of events:

  • Deleting a series does not delete occurrences that have already happened.
  • When an event owner deletes a series of recurring events, all invited users receive a single email notifying them that the series of events has been canceled.
  • If a series is deleted and no events in the series occurred in the past, the series is placed in the Recycle Bin. Individual events that were part of the series are not placed in the Recycle Bin.
  • If a series is deleted and it contains events that occurred in the past, the series is not placed in the Recycle Bin, and therefore it cannot be restored from the Recycle Bin.
  • If you restore a series from the Recycle Bin, individual events will be created. Those individual events will have the details as defined by the series, as well as any event-specific details that were set on the event before the series was deleted.
mdelgadomdelgado

Hi Umesh,

 

Thanks again for your reply.  I don't believe its a reoccurring event.  The query (in code snippet) specifies: IsRecurrence = false

 

For now I have implemented a try/catch block when attempting to delete record.  That seems to have solved my problem.

 

thanks,

 

Mirko