function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Need Salesforce Developer to Build an Apex Trigger

We are currently using a single Salesforce account to manage all our brands (currently three) and a third party platform (Pardot) to create landing pages and forms for lead acquisition.  Pardot works by linking one Salesforce record to a single Pardot record and syncing the two together.  If a lead submits multiple forms for different brands the original record is updated instead of a new lead record being created in Salesforce.  This is a problem for us because our sales reps do not cross-sell between brands.

As a work around we would like to have Salesforce create a new lead record whenever a form is submitted and the brands do not match, even if the email addresses are the same.

The final lead flow should something like the following:
1.) De-dupe the incoming email address
          -If the email address doesn't currently exist in Salesforce then create a new lead.
          -If the email is a duplicate then compare brands.
2.) If the brand matches then update the current record.
3.) If the brand doesn't match then create a new lead record and assign the new record to a sales rep.

Contact my mail for immediate resolution of the task
Hareesh KHareesh K

I'm interested on your job. I have 4+ experience in apex/SF. Please share your details to my email id:

Rejith VarmaRejith Varma

I am Rejith, leading the Salesforce practice at QBurst. (holds 5 Salesforce certifications) . You can see my detailed profile here at

I have 5 years of strong experience in CRM consulting and Salesforce implementations.

Looking at the high level requirements, we feel confident of helping you achieve your business objectives quickly. We would like to have a call with you so that we can introduce my company and myself in more detail in the call. We can also clarify some questions regaridng the requirements. Can we connect today or tomorrow morning? My skype id is Rejith.Varma

Looking forward to talking to you.

best regards,
Chinmay BhusariChinmay Bhusari
Hi elukavsky,
trigger avoidDuplicates on Lead (before insert) {
  for (Lead myLead : {
    if (myLead.Email != null) {
      List<Lead> dupes = [SELECT Id FROM Lead
                               WHERE Email = :myLead.Email];
     //if duplicate is found
        if (dupes.size() > 0) {
            // Brand matches
                //give new lead values to dupes
                //update dupes;
               myLead.addError('Found Duplicate');
        //if duplicate is not found
        //then it will insert anyhow


That code up above has a select statement inside a loop. Awful coding practice.
Rejith VarmaRejith Varma

Has your issue been resolved?  we would like to help you with your trigger development. Can we talk sometime this week?
My skype is is Rejith.Varma

best regards,