Trigger code below working but I want in flows
trigger PreventContactsTrigger on Account (before delete)
{
if(Trigger.isDelete && Trigger.isBefore)
{
// Get the Related Contacts for the Deleting Accounts..
List lstContacts = [Select id, firstname, lastname, accountid
from Contact
Where AccountID IN : Trigger.OldMap.KeySet()];
if(! lstContacts.isEmpty())
{
for(Contact con : lstContacts)
{
con.AccountId = null;
}
update lstContacts;
}
}
}
Hi Saki,
This might not be possible if you delete account, contacts would be deleted since they have parent child relationship.
Check below code snippet to have validation on account cannot be deleted if it has related contacts
Please mark as Best Answer if above information was helpful.
Thanks,