I wrote triggers that will be fired after inserting/updating/deleting task and event. What the triggers do is HTTP call out. When a lead is convert, tasks and events will be copied too, so the triggers are fired and give a "too many future task" exception.
After discussing with my project manager, we decided that, on lead conversion, copying tasks and events is required but the HTTP callout triggers are not.
I don't want the triggers to be fired on lead conversion. What should I do? Or how could the task/event trigger check that a user is converting a lead.
According to this page Understanding Lead Conversion I tried disabling validation and triggers for lead convert. But the task and event triggers were still fired. (I think only lead/account/contact/opportunity's trigger were disabled.)
Any help would be appreciated.
According to this page, I think, when a lead is converted, an account/contact/opportunity will be created before lead.InConverted is changed to true. I tried creating triggers to test the conversion flow. The test result shown below.
Trigger on Account is fired. Triggers on Task/Event are fired. Trigger on Lead is fired.
So, I create a class which contains only a static boolean like checkLeadConvertIsInProgress == false. And in a trigger on Account, I set checkLeadConvertIsInProgress == true.
When the trigger on Task is fired, the trigger will check on checkLeadConvertIsInProgress, if true, skip the HTTP callout, otherwise do the callout.
Thank you for all your helps!