You need to sign in to do that
Don't have an account?
Jack Ins
Relating Lead record to Contact record after update.
Hi all,
I need to create a trigger to relate a lead after update or insert to an existing contact record. Both will have an identifier to make the relationship. Just not sure how to write the trigger. My code is attached. I have started the trigger but I am now stuck.
Any help would be great.
Thanks Dwayne
trigger LeadCnsmrContactAssoc on Lead (after insert, after update) { List<Contact> cntList = new List<Contact>(); for (Lead l: Trigger.new) { if (l.ld_plcsc_Customer_Number__c != null) { try { Contact cnt = [select id, cnt_plcsc_CustNmbr_ExtID__c from Contact where cnt_plcsc_CustNmbr_ExtID__c =: l.ld_plcsc_Customer_Number__c limit 1]; //cntList.Lead = l.Id;// cntList.add(cnt);} catch (Exception e) {System.debug('Contact Record Does Not Exist.');} } } if (cntList.size() > 0) update cntList; }
Got it. Was able to figure it out.