You need to sign in to do that
Don't have an account?
Janno Rip
Custom Object Conversion - Get Name and Company
Hello everyone,
I have a custom object called "Leadevents__c" that can be attached to Leads and Accounts. In the screenshot it is attached to Lead:
After conversion it will get attached to an account. We have an apex class in place that provides this:
However I lose the contact on my way from Lead to Account. What I would need is the following result:
The challenge is that the apex class provinding said usability is over 10 years old and not mine. I was able (at least I think so) to figure out the code responsable:
I added "Kontakt__c" so that I could refer to "le.Kontakt__c" and give it a value. Now I have a fix contact ID in there which actually works. When I convert a lead, this contact ID is attached to the "leadevent__c". Obviously I need a dynamic verison. Is anyone able to review this code and tell me if this is the right place and what I would need to achieve this?
Thanks guys!
I have a custom object called "Leadevents__c" that can be attached to Leads and Accounts. In the screenshot it is attached to Lead:
After conversion it will get attached to an account. We have an apex class in place that provides this:
However I lose the contact on my way from Lead to Account. What I would need is the following result:
The challenge is that the apex class provinding said usability is over 10 years old and not mine. I was able (at least I think so) to figure out the code responsable:
I added "Kontakt__c" so that I could refer to "le.Kontakt__c" and give it a value. Now I have a fix contact ID in there which actually works. When I convert a lead, this contact ID is attached to the "leadevent__c". Obviously I need a dynamic verison. Is anyone able to review this code and tell me if this is the right place and what I would need to achieve this?
Thanks guys!
Greetings to you!
Please use below line of code:
I hope it helps you.
Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future.
Thanks and Regards,
Khan Anas
All Answers
Greetings to you!
Please use below line of code:
I hope it helps you.
Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future.
Thanks and Regards,
Khan Anas
Hallo Khan,
thanks for your insight. While I can save my apex class without getting any error messges, I get an error during the conversion process:
LeadConvert: execution of AfterUpdate caused by: System.NullPointerException: Attempt to de-reference a null object Class.AK_LeadEvents.leadMoveEvents: line 19, column 1 Trigger.LeadConvert: line 5, column 1
line 19, column 1 is the new part: le.Kontakt__c = leadNew.get(le.Lead__c).ConvertedContactId;
here is the code of the trigger:
I fixed it myself by classic try and error. The trick was to "delete" / "deactivate" the following:
le.Lead__c = null needs to be gone