You need to sign in to do that
Don't have an account?
sandy sfdc
Stop Account trigger when lead converting
Hi,
I need to stop account trigger(Insert Event) while im converting lead to account.
trigger accounttrigger on Account(after insert)
{
set<Id>ids=new Set<Id>();
if(trigger.isAfter && trigger.Isinsert){
for(Account a:trigger.new){
ids.add(a.id);
}
if(ids.size()>0){
//do my stuff
//this block cannot be called while Lead Convertion
}
}
}
So,please can any one help on this.
I need to stop account trigger(Insert Event) while im converting lead to account.
trigger accounttrigger on Account(after insert)
{
set<Id>ids=new Set<Id>();
if(trigger.isAfter && trigger.Isinsert){
for(Account a:trigger.new){
ids.add(a.id);
}
if(ids.size()>0){
//do my stuff
//this block cannot be called while Lead Convertion
}
}
}
So,please can any one help on this.
All Answers
and then in your lead convert code you would set CONVERTING_LEAD to true
[1] http://blog.deadlypenguin.com/blog/2012/02/13/classifying-triggers-in-salesforce/
Setup--> Lead Setting --> Require Validation for Converted Leads .
It will stop the following actions as well.
field validation rules, workflow actions, and Apex triggers.
Even though it was unchecked,triggers are firing on Account,Contact and Opportunity
we implemented below flow but we never succeded.can you please update us.i.e,we were failed to stop Account trigger(Insert) when Lead convertion.
My Lead Trigger
trigger Leadtrigger on Lead (after update) {
set<Id>lids=new Set<Id>();
if(trigger.isAfter && trigger.Isupdate){
for(Lead a:trigger.new){
lids.add(a.id);
if(a.IsConverted==true){
stopexceutioncontroller.CONVERTING_LEAD=true;
}
}
if(lids.size()>0){
// calling my api call
myownclass.mymethod2(lids);
}
}
}
MY Account Trigger
trigger accounttrigger on Account(after insert)
{
set<Id>ids=new Set<Id>();
if(trigger.isAfter && trigger.Isinsert){
if(!stopexceutioncontroller.CONVERTING_LEAD){
//just im lookking this block never called when Lead convertion
for(Account a:trigger.new){
ids.add(a.id);
}
if(ids.size()>0){
//calling my api class
myownclass.mymethod(ids);
}}}}
MY API class
public with sharing class myownclass{
@Future(callout=true)
public static void mymethod(Set<Id>ids)
{
system.debug('------------------Account API future-------------'+ids);
//http callouts
}
public static void mymethod2(Set<Id>ids)
{
system.debug('------------------Lead API future-------------'+ids);
//http callouts
}
}
MY Static Class
public class stopexceutioncontroller{
public static Boolean CONVERTING_LEAD = false;
}