+ Start a Discussion

How to avoid campaign trigger when deleting campaign member?

I believe deleting campaign member will call the trigger on campaign because of roll up for "NumberOfContacts" but i want to avoid my custom trigger ? what is the workaround for this?


Sure the trigger will fire beacuse of change in related list and change in rollup . if you add the below logic in starting of the trigger 


if(Trigger.New[0].total_number_of_contacts__c ==trigger.old[0].total_number_of_contacts__c)

////  all the trigger logic 



that will not cause the trigger to perform any action whn there will be a change in "NumberOfContacts"


Not very sure if we are able to stop execution on the trigger . hope this hepls .......




NumberOfContacts is standard field from salesforce . The weird part is when i delete campaignmeber then check the value of  NumberOfContacts both old and new always has same value so i cannot define if condition in my trigger


in case of standard field ,Trigger will not get fire . check in your debug log then you will be sure . 


i have no trigger in campaign member. In user interface i delete 1 campaign member under campaign record. and i see in debug log that it goes to campaign trigger. how to avoid to go to campaign trigger if i only deleting campaign member .

see below debug log


02:45:17.262 (262040000)|EXECUTION_STARTED
02:45:17.262 (262081000)|CODE_UNIT_STARTED|[EXTERNAL]|TRIGGERS
02:45:17.262 (262108000)|CODE_UNIT_STARTED|[EXTERNAL]|01qc0000000CjBw|preventInvalidMember on Campaign trigger event BeforeUpdate for [701c000000011vm]
02:45:17.263 (263984000)|SYSTEM_CONSTRUCTOR_ENTRY|[3]|<init>(Integer)
02:45:17.264 (264041000)|SYSTEM_CONSTRUCTOR_EXIT|[3]|<init>(Integer)
02:45:17.264 (264247000)|SYSTEM_CONSTRUCTOR_ENTRY|[5]|<init>(Integer)
02:45:17.264 (264285000)|SYSTEM_CONSTRUCTOR_EXIT|[5]|<init>(Integer)
02:45:17.264 (264450000)|SYSTEM_METHOD_ENTRY|[8]|LIST<Campaign>.size()
02:45:17.264 (264492000)|SYSTEM_METHOD_EXIT|[8]|LIST<Campaign>.size()
02:45:17.265 (265465000)|SYSTEM_METHOD_ENTRY|[10]|SET<Id>.add(Object)
02:45:17.265 (265513000)|SYSTEM_METHOD_EXIT|[10]|SET<Id>.add(Object)
02:45:17.265 (265540000)|SYSTEM_METHOD_ENTRY|[8]|LIST<Campaign>.size()
02:45:17.265 (265551000)|SYSTEM_METHOD_EXIT|[8]|LIST<Campaign>.size()
02:45:17.265 (265575000)|SYSTEM_METHOD_ENTRY|[14]|SET<Id>.size()