0

We have started using salesforce in August 2020. Recently I've noticed that some of the leads (mostly) and opportunities are starting to disappear. I've found them in our organisation's Recycle Bin. I contacted salesforce support but they said they have no expertise and possibility to help me with this case.

However, one of their support consultants told me that there is a trigger on a lead object. I couldn't edit it in production and I am supposed to edit it in the sandbox first, then deploy to production from sandbox.

They said that the code in the trigger is the following.

trigger lead on Lead (before insert, after insert, before update, after update, after delete) {
    if (Trigger.isInsert && Trigger.isBefore && leadTriggerHelper.fireTrigger) {
        leadTriggerHelper.insertLead(Trigger.new);
    }
    if (Trigger.isInsert && Trigger.isAfter && leadTriggerHelper.fireTrigger && TriggerHelperUtil.canScheduleQueueable()) {
        System.enqueueJob(new DuplicateEmailCheckQueueable(Trigger.newMap, Lead.class.toString()));
    }
    if (Trigger.isUpdate && Trigger.isBefore && leadTriggerHelper.fireTrigger) {
        leadTriggerHelper.updateLead(Trigger.newMap, Trigger.oldMap);
    }
    if (Trigger.isUpdate && Trigger.isAfter && leadTriggerHelper.fireTrigger) {
        Set<String> updatedEmails = TriggerHelperUtil.checkForEmailChange(Trigger.newMap, Trigger.oldMap);
        if(!updatedEmails.isEmpty() && TriggerHelperUtil.canScheduleQueueable()) {
            System.enqueueJob(new DuplicateEmailCheckQueueable(updatedEmails, Lead.class.toString()));
        }
        leadTriggerHelper.afterUpdateLead(Trigger.newMap, Trigger.oldMap);
    }
    if (Trigger.isDelete) {
        leadTriggerHelper.deleteLead(Trigger.old);

Does anyone know what is this trigger and could it cause the leads to be deleted for some stupid reason? I am not sure if I can safely delete it. It is 100% not a code that one of our employees have put as they have no access to it, but it could be a trigger that was inserted by activecampaign integration. Still, I have no idea how to get rid of it properly.

0

This trigger code doesn't do anything by itself. It calls a number of other code units depending on what event fired it, including DuplicateEmailCheckQueueable, leadTriggerHelper, and TriggerHelperUtil. These may implement any number of different functionalities.

The line you may be suspecting,

    leadTriggerHelper.deleteLead(Trigger.old);
    

is executed only if the Lead is already being deleted, so it's not the root cause of your problem (although it could potentially be deleting records like Opportunities when a Lead is deleted, that would be quite a strange automation).

There's no reason from the information given to disable this trigger, and doing so might harm your organization's business processes. If I were you, I would focus on reproducing the record deletions (assuming you've established to your satisfaction that the cause is neither user error nor user malice), which can help guide you as to where to look for any automation that may be involved.

Alternately, engage the organization that built our your Salesforce org for assistance.

1
  • Thank you, David, that is really helpful. Maybe I will manage to convince the salesforce support to dig deeper into that.
    – Sunny
    Nov 20 '20 at 14:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.