Skip to main content
Prashanthkumar Annarapu a posé une question dans #Apex
trigger realtedaccounttrigger on Account (before delete)

{

    if(Trigger.isbefore&&Trigger.Isdelete)

    {

        List<contact>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;

        }

    }

}

this code is for deletion for the related contact record .if we want related contact record also can u give me that code  
6 réponses
0/9000