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
Jerrod Knapp 25Jerrod Knapp 25 

Created after delete trigger now i can't delete records

I've created a simple trigger on contact to check a box after delete.  When I activate the trigger I can no longer delete a contact.  Error: "There's a problem saving this record. You might not have permission to edit it, or it might have been deleted or archived. Contact your administrator for help."
Trigger:
trigger trgDeletedContact on Contact (after delete) {
    for (Contact c: trigger.old){
        c.IsDeleted__c = TRUE;
    }
}

Thanks in advance!
SATHISH REDDY.SATHISH REDDY.
I would say to use the following instead.
trigger trgDeletedContact on Contact (before delete) {
    for (Contact c: trigger.new){
        c.IsDeleted__c = TRUE;
    }
}

 
SATHISH REDDY.SATHISH REDDY.
Please mark as best answer if this helps. Thanks!
Jerrod Knapp 25Jerrod Knapp 25
Thank you, however, that did not work.  In fact, even if I inactivate the trigger it keeps me from deleting the contact record.  Only if I delete the trigger does it allow me to delete a record.
Rajesh3699Rajesh3699
Hi ,

You cannot update the record once it is deleted. You can go with before delete event [ subject to your requirement ] 

Nor you will not be able to see the record unless you undelete it

Thank You,
Rajesh Adiga P.
SATHISH REDDY.SATHISH REDDY.
@Jerrod - If this is something you need it, then the nasty workaround would be to capture the Ids of the After Delete Contacts & undelete----Update-------Then Delete. Thats the only option i could think of to update the deleted record.
mukesh guptamukesh gupta
Hi Jerrod,

you need to use before delete
trigger deleteContact on Contact (before delete) {
    for (Contact c: trigger.new){
        c.IsDeleted__c = TRUE;
    }
}

Kindly MARK AS A BEST ANSWER!!if the reply was helpful.


Regards
Mukesh
Jerrod Knapp 25Jerrod Knapp 25
Satish suggested that, see above.