+ Start a Discussion
anna425912anna425912 

How can I prevent a contact trigger from running when a lead is converted?

I have a before insert, before update trigger on the contact that is causing issues when a lead is converted.  I don't need the triggers to run on lead conversion though so how can I write this into my trigger or class?
olegforceolegforce
Short answer is there is no easy way. Long answer, have a checkbox checked on the contact when lead is converted by mapping fields and then have it shecked on the leads by default or on conversion. I think... Just came up with this one so you might need to try it out. Should work. You still need to adjust trigger on the contact to account for a new checkbox... 

Why not fix the trigger in the first place? :)
anna425912anna425912
I would love to just fix the trigger, but I haven't figured that out yet. And the error I'm getting isn't telling me much:
"caused by: System.DmlException: ConvertLead failed. First exception on row 0; first error: UNKNOWN_EXCEPTION, An unexpected error occurred. Please include this ErrorId if you contact support: 895837233-71188 (-43640737): []"
olegforceolegforce
This is just a guess, but it might be due to invalid user id or user is inactive. Do you do anything with user assignment in this contact trigger? 
olegforceolegforce
your lead might have an inactive user or be assigned to a queue or something.
MagulanDuraipandianMagulanDuraipandian
Create a static variable in apex class. Similar to avoiding Recursive triggers.

http://www.infallibletechie.com/2012/08/recursive-triggers-in-salesforce.html

If this solves your problem, kindly mark it as the best answer.

Regards,
Magulan
http://www.infallibletechie.com
Vinit_KumarVinit_Kumar
You can check for ConvertedContactId in your Trigger to see if the Lead is converted or not because during Lead conversion the ConvertedContactId is generated.