You need to sign in to do that
Don't have an account?
Please Help me to fix this
trigger LeadConversionTrigger on Lead( after update)
{
for( Lead l : Trigger.new )
{
// Check if the Lead is converting.
//Once Lead is converted, Lead is read-only so this can only happen once
if ( l.isConverted )
{
// Obtain a list of cases associated to the Lead
List< Case > CasesToConvert = [SELECT Id, Lead__c, ContactId, AccountId FROM Case WHERE Lead__c = l.Id];
// Update the Cases associated to the Lead to its converted Contact and Account Id
if ( CasesToConvert.size() > 0 )
{
for ( Case c : CasesToConvert )
{
c.ContactId = l.ConvertedContactId;
c.AccountId = l.ConvertedAccountId;
}
// Update the Cases
update CasesToConvert;
}
}
}
}
Yes, I missed it. I have updated the code now and has put some additional check as well.
If above solution helps, Please mark it as best answer.
Thanks,
All Answers
Can you update the code as below. It workedn.
If this solution helps, Please mark it as best answer.
Thanks,
please correct me
Yes, I missed it. I have updated the code now and has put some additional check as well.
If above solution helps, Please mark it as best answer.
Thanks,
please provide me an email id for further communication
thank you