You need to sign in to do that
Don't have an account?

how to reference contact id..???
trigger test1 on Lead (after insert) { Set<ID> ls = new Set<ID> (); for(Lead l:Trigger.new) { ls.add(l.id); } List<Lead> lis=[Select Id,Name, Status,Email,Company,fax,from Lead where id in:ls]; List<Contact> con=[Select Id,Name ,Email_2__c,fax from Contact ]; List<Contact> lstContact = new List<Contact>(); for(Lead ld:lis) { for(Contact cn:con) { Contact objC= new Contact(); objC.FirstName=ld.FirstName; objC.LastName=ld.LastName; lstContact.add(objC); } customobj.lookupfield=objC.Id;//Here i am getting nothing ie id is null here...can u pl help } if(lstContact.size() > 0 ) insert lstContact; } i am getting nothing ie id is null here...can u pl help..i want to get the recently created id there..did you understand what i am asking for...thanks for replying....:)
how to reference contact id of the record which is inserted when the lead is created....
You are trying to access id field of contact , before inserting contact.
First insert contactList and then access its Id
Thanks,
bForce
All Answers
You are trying to access id field of contact , before inserting contact.
First insert contactList and then access its Id
Thanks,
bForce
Duplicate post for:
http://boards.developerforce.com/t5/Apex-Code-Development/trigger-help-how-to-get-contact-id/td-p/413613