• Daniel Gage
  • NEWBIE
  • 85 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 10
    Questions
  • 33
    Replies
This was working a couple of weeks ago, and I added some code to deal with some duplication control. And now it's not even populating the Map during the test, so it's only got 19 percent coverage.
First is the Trigger... When testing against the class (in the next post)..... the MVmap.put commands are all red. So it's never getting to that portion of the code. And I can't for the life of me figure out why. It was working. Now it isn't.

trigger UpdateLeadVerification on Lead (before insert, before update) {
    List<String> leadEmails = new List<String>();
    Map<String, Member_Verification__c > MVMap = new  Map<String, Member_Verification__c >();

    for(Lead lead:Trigger.new){
        leadEmails.add(lead.Email);
        leadEmails.add(lead.Verification__c);
        leadEmails.add(lead.Verification1__c);
        leadEmails.add(lead.Verification2__c);
        leadEmails.add(lead.Verification3__c);
    }
    for(Member_Verification__c member :[SELECT Id, Primary_Email__c, Verification__c, Verification1__c, Verification2__c, Verification3__c,TFA_Salesforce_ID__C, Lee_Member__c FROM Member_Verification__c
                                        WHERE ((Primary_Email__c != null and Primary_Email__c IN :leadEmails) or (Verification__c IN :leadEmails)
                                       or (Verification1__c IN :leadEmails) or (Verification2__c IN :leadEmails) or (Verification3__c IN :leadEmails))]
       
       ){
        MVmap.put(member.Primary_email__c , member);
           MVmap.put(member.Verification__c , member);
           MVmap.put(member.Verification1__c , member);
           MVmap.put(member.Verification2__c , member);
           MVmap.put(member.Verification3__c , member);

          
    }
    
    for(Lead leadObj:Trigger.new){
        if(MVmap.ContainsKey(leadObj.Email) || MVmap.ContainsKey(leadObj.Verification__c) || MVmap.ContainsKey(leadObj.Verification1__c) || MVmap.ContainsKey(leadObj.Verification2__c) || MVmap.ContainsKey(leadObj.Verification3__c)){
            If (MVmap.get(leadObj.Email) != Null){
                If(MVmap.get(LeadObj.Email).Lee_member__c != True){
                leadObj.TFA_Salesforce_ID__c = MVmap.get(leadObj.Email).TFA_Salesforce_ID__C ;
                leadObj.Member_Verification_Record__c = MVmap.get(leadObj.Email).id;
                LeadObj.Verified__c = True;
                MVmap.get(leadObj.Email).Lee_Member__c = true;
                update MVmap.get(leadObj.Email);
            } else
                If(MVmap.get(LeadObj.Email).Lee_member__c != False){
                leadObj.Member_Verification_Record__c = MVmap.get(leadObj.Email).id;    
                LeadObj.status = 'Closed - Duplicate';
                }
                    
            }
           If (MVmap.get(leadObj.Verification__c) != Null){
               If(MVmap.get(LeadObj.Verification__c).Lee_member__c != True){
                leadObj.TFA_Salesforce_ID__c = MVmap.get(leadObj.Verification__c).TFA_Salesforce_ID__C ;
                leadObj.Member_Verification_Record__c = MVmap.get(leadObj.Verification__c).id;
                LeadObj.Verified__c = True;
                MVmap.get(leadObj.Verification__c).Lee_Member__c = true;
                update MVmap.get(leadObj.Verification__c);
               } else
               If(MVmap.get(LeadObj.Verification__c).Lee_member__c != False){
                   leadObj.Member_Verification_Record__c = MVmap.get(leadObj.Verification__c).id;
                  LeadObj.status = 'Closed - Duplicate';  
               }
               }
                
           If (MVmap.get(leadObj.Verification1__c) != Null){
               If(MVmap.get(LeadObj.Verification1__c).Lee_member__c != True){
               leadObj.TFA_Salesforce_ID__c = MVmap.get(leadObj.Verification1__c).TFA_Salesforce_ID__C ;
                leadObj.Member_Verification_Record__c = MVmap.get(leadObj.Verification1__c).id;
                   LeadObj.Verified__c = True;
                MVmap.get(leadObj.Verification1__c).Lee_Member__c = true;
                update MVmap.get(leadObj.Verification1__c);
                           } else
               If(MVmap.get(LeadObj.Verification1__c).Lee_member__c != False){
                   leadObj.Member_Verification_Record__c = MVmap.get(leadObj.Verification1__c).id;
                  LeadObj.status = 'Closed - Duplicate';  
               }
           }
            
            If (MVmap.get(leadObj.Verification2__c) != Null){
                If(MVmap.get(LeadObj.Verification2__c).Lee_member__c != True){
                leadObj.TFA_Salesforce_ID__c = MVmap.get(leadObj.Verification2__c).TFA_Salesforce_ID__C ;
                leadObj.Member_Verification_Record__c = MVmap.get(leadObj.Verification2__c).id;
                    LeadObj.Verified__c = True;
                MVmap.get(leadObj.Verification2__c).Lee_Member__c = true;
                update MVmap.get(leadObj.Verification2__c);
                
                } else
               If(MVmap.get(LeadObj.Verification2__c).Lee_member__c != False){
                   leadObj.Member_Verification_Record__c = MVmap.get(leadObj.Verification2__c).id;
                  LeadObj.status = 'Closed - Duplicate';  
               }
           }
            
            If (MVmap.get(leadObj.Verification3__c) != Null){
                If(MVmap.get(LeadObj.Verification3__c).Lee_member__c != True){
                leadObj.TFA_Salesforce_ID__c = MVmap.get(leadObj.Verification3__c).TFA_Salesforce_ID__C ;
                leadObj.Member_Verification_Record__c = MVmap.get(leadObj.Verification3__c).id;
                LeadObj.Verified__c = True;
                MVmap.get(leadObj.Verification3__c).Lee_Member__c = true;
                update MVmap.get(leadObj.Verification3__c);
                
                } else
               If(MVmap.get(LeadObj.Verification3__c).Lee_member__c != False){
                   leadObj.Member_Verification_Record__c = MVmap.get(leadObj.Verification3__c).id;
                  LeadObj.status = 'Closed - Duplicate';  
               }
           }
            
            
        }

        }

}
Can't get any coverage on this, and can't figure out why. Both this class and the test cases were written by another developer (who is not available anymore to ask questions of). But I can't get any coverage on this no matter what I try. Any help is greatly appreciated.

Going to have to put this code up in parts as it is too large.
public without sharing class MyProfileController {
    public String fname{set;get;}
    public String lname{set;get;}
    public String fullmiddelname{set;get;}
    public String pemail{set;get;}
    public String semail{set;get;}
    public String mobile{set;get;}
    public String home{set;get;}
    public String work{set;get;}
    public String street{set;get;}
    public String city{set;get;}
    public String state{set;get;}
    public String zip{set;get;}
    public String country{set;get;}
    public String facebook{set;get;}
    public String twitter{set;get;}
    public String linkedin{set;get;}
    public String birthdate{set;get;}
    public String gender{set;get;}
    public String race{set;get;}
    public String profession{set;get;}
    public String pinterest{set;get;}
    public String ainterest{set;get;}    
    public String ointerest{set;get;}    
    public String corpregion{set;get;}
    public String alumniregion{set;get;}
    public String corpregionView{set;get;}
    public String alumniregionView{set;get;}
    public String corpYear{set;get;}
    public boolean HasOptedOutOfEmail{get;set;}
    public boolean DoNotCall{get;set;}
    public boolean memberoptout{set;get;}
    public List<SelectOption> corpRegions{get;set;}
    public List<SelectOption> advocacyInterests{get;set;}
    public List<SelectOption> policyInterests{get;set;}
    public List<SelectOption> organizingInterests{get;set;}
    public List<SelectOption> ethnicityOntions{get;set;}
    public blob imagebody{set;get;}
    public string imageName{set;get;}
    public string imagesrc{set;get;}
    public string imagesrc1{set;get;}
    public boolean isEditable{set;get;}
    public boolean registered{set;get;}
    public String leadership{set;get;}
    public List<SelectOption> leaderships{get;set;}
    public List<SelectOption> volunteerInterests{get;set;}
    public String volunteerInterest{set;get;}
    List<Region__c> corpRegionsList;
    List<Region__c> alumniRegionsList;
    Map<String,Region__c> regionsMap;
    String oldZip;
    String contactId;
    List<Attachment> att;
    public Contact con{set;get;}
    Attachment img;
    Contact_Picture__c contactImage;
    public LEE_Campaign__c leecamp{set;get;}
    public boolean showErr{set;get;}
    List<Region_ZipCode__c> zipcodes;
    List<Region_Membership__c> regionMembers;
    Decimal filesize;
    public boolean isError{set;get;}
    public String errorMsg{set;get;}
    public string title{set;get;}
    public string employer{set;get;}
    public MyProfileController(){
        isError = false;
        regionsMap = new Map<String,Region__c>();
        leecamp = new LEE_Campaign__c();
        showErr = false;
        User loggedUser = [SELECT id,ContactID from User WHERE Id=: userInfo.getUserId()];
        //contactId = ApexPages.currentPage().getParameters().get('id');
        contactId = loggedUser.ContactId;
       // contactId = '003M000000Dp9z9';
        isEditable = false;
        policyInterests =  new List<SelectOption>();
        advocacyInterests = new List<SelectOption>();
        organizingInterests = new List<SelectOption>();
        ethnicityOntions = new List<SelectOption>();
        leaderships = new List<SelectOption>();
        volunteerInterests  = new List<SelectOption>();
        //Populate Advocacy Interest Picklist
        Schema.DescribeFieldResult fieldResult = Contact.Advocacy_Interest__c.getDescribe();
        List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();
        for(Schema.PicklistEntry f : ple){
            advocacyInterests.add(new SelectOption(f.getLabel(), f.getValue()));
        }
        //Populate Policy Interest Picklist
        fieldResult =  Contact.Policy_Interest__c.getDescribe();
        ple = fieldResult.getPicklistValues();
        for(Schema.PicklistEntry f : ple){
            policyInterests.add(new SelectOption(f.getLabel(), f.getValue()));
        }
        
        //Populate Organizing Interest Picklist
        fieldResult =  Contact.Organizing_Interest__c.getDescribe();
        ple = fieldResult.getPicklistValues();
        for(Schema.PicklistEntry f : ple){
            organizingInterests.add(new SelectOption(f.getLabel(), f.getValue()));
        }
        //Populate Ethnicity Picklist
        fieldResult =  Contact.Ethnicity__c.getDescribe();
        ple = fieldResult.getPicklistValues();
        for(Schema.PicklistEntry f : ple){
            ethnicityOntions.add(new SelectOption(f.getLabel(), f.getValue()));
        }
        
        //Populate Public Leadership Aspirations Picklist
        fieldResult =  Contact.Public_Leadership_Aspirations__c.getDescribe();
        ple = fieldResult.getPicklistValues();
        for(Schema.PicklistEntry f : ple){
            leaderships.add(new SelectOption(f.getLabel(), f.getValue()));
        }
        //Populate Volunteer Interests Picklist
        fieldResult =  Contact.Volunteer_Interests__c.getDescribe();
        ple = fieldResult.getPicklistValues();
        for(Schema.PicklistEntry f : ple){
            volunteerInterests.add(new SelectOption(f.getLabel(), f.getValue()));
        }
        
        //contactId = ApexPages.currentPage().getParameters().get('contactId');
        corpRegions = new List<SelectOption>();
        corpRegionsList = [SELECT id,Name from Region__c];
        //Populate Corp Region and Amumni Region Picklist
        if(corpRegionsList != null && corpRegionsList.size() > 0){
            for(Region__c r: corpRegionsList){
                corpRegions.add(new SelectOption(r.Id,r.Name));
                regionsMap.put(r.Name,r);
            }
        }else{
            corpRegions.add(new SelectOption('',''));
        }
        
        if(contactId != null && contactId.trim().length() > 0){
            con = [Select c.Twitter__c,  c.Secondary_Email__c,
                        c.Ethnicity__c, c.Profession__c, c.Policy_Interest__c, Volunteer_Interests__c,
                        c.Phone,  c.Organizing_Interest__c, c.Name, c.MobilePhone, c.Member_Stage__c,
                        c.MailingStreet, c.MailingState, c.MailingPostalCode, c.MailingCountry, c.MailingCity, c.DoNotCall,
                        c.Linked_In__c, c.LeadSource, c.LastName,  c.Id, c.HomePhone, Registered_to_Vote__c,
                        c.Gender__c, c.Full_Middle_Name__c, c.FirstName, c.Fax, c.Facebook__c, Public_Leadership_Aspirations__c,
                        c.Email,c.Corps_Year__c, c.Corp_Region__c, c.Birthdate, c.Alumni_Region__c, c.Advocacy_Interest__c, c.HasOptedOutOfEmail,
                        c.Employee_Title__c,c.Employment_Organization__c
                    From Contact c
                    WHERE Id=: contactId];
                    
            if(con != null){
                fname = con.FirstName;
                lname = con.LastName;
                fullmiddelName = con.Full_Middle_Name__c;
                home = con.HomePhone;
                mobile = con.MobilePhone;
                work = con.Phone;
                pemail = con.Email;
                semail = con.Secondary_Email__c;
                facebook = con.Facebook__c;
                twitter = con.Twitter__c;
                linkedin = con.Linked_In__c;
                street = con.MailingStreet;
                city = con.MailingCity;
                state = con.MailingState;
                zip = con.MailingPostalCode;
                oldZip = zip;
                country = con.MailingCountry;
                title = con.Employee_Title__c;
                employer = con.Employment_Organization__c;
                //birthdate = String.valueOf(con.BirthDate);
                race = con.Ethnicity__c;
                profession = con.Profession__c;
                gender = con.Gender__c;
                pinterest = con.Policy_Interest__c;
                ainterest = con.Advocacy_Interest__c;
                ointerest = con.Organizing_Interest__c;
                corpregion = con.Corp_Region__c;
                alumniregion = con.Alumni_Region__c;
                if(con.HasOptedOutOfEmail != null)
                    HasOptedOutOfEmail = con.HasOptedOutOfEmail;
                else
                    HasOptedOutOfEmail = false;
                if(con.DoNotCall != null)
                    DoNotCall = con.DoNotCall;
                else
                    DoNotCall = false;
                for(SelectOption so:corpRegions){
                    if(so.getValue() == corpregion){
                        corpregionView = so.getLabel();
                    }
                }
                
                for(SelectOption so:corpRegions){
                    if(so.getValue() == alumniregion){
                        alumniregionView = so.getLabel();
                    }
                }
                corpYear = con.Corps_Year__c;
                if(con.Member_Stage__c == 'Deactivated'){
                    memberoptout = true;
                }else{
                    memberoptout = false;
                }
                registered = con.Registered_to_Vote__c;
                String str = con.Public_Leadership_Aspirations__c;
                
                /*str = str.replaceAll(';',',');
                str ='['+str + ']';*/
                leadership = str;
                System.Debug('@@@@@@@@Value'+leadership);
                volunteerInterest = con.Volunteer_Interests__c;
                
                List<Contact_Picture__c> contactImages = [SELECT id,Contact__c from Contact_Picture__c WHERE Contact__c =: con.id];
                if(contactImages != null && contactImages.size() >0){
                    contactImage = contactImages[0];
                    att = [SELECT id,Name from Attachment WHERE parentId =: contactImage.Id Order By CreatedDate Desc LIMIT 1];
                    if(att != null && att.size() > 0){
                        System.Debug('######Attachment ID'+att[0].id);
                        //imagebody = att[0].body;
                       /* imagesrc1 = String.valueOf(imagebody);
                        System.Debug('######Image Body'+imagesrc1);*/
                        //imageName = att[0].Name;
                        imagesrc = '/servlet/servlet.FileDownload?file='+att[0].id;
                    }
                }
                
            }else{
                con = new Contact();
            }
        }
    }
    public void upload(){       
        if(imageName != null && imageBody != null){
            filesize = imageBody.size();
            filesize = filesize /(1024*1024);
            if(filesize <= 1){
                if(con != null && con.id != null){
                    if( contactImage != null && contactImage.Contact__c != null){
                        img = new Attachment(Name = imageName,Body=imageBody,ParentId = contactImage.id);
                        insert img;
                    }else{
                        contactImage = new  Contact_Picture__c(Contact__c = con.Id);
                        insert contactImage;
                        img = new Attachment(Name = imageName,Body=imageBody,ParentId = contactImage.id);
                        insert img;
                    }
                    imagesrc = '/servlet/servlet.FileDownload?file='+img.id;
                    imageBody = null;
                    img = null;
                    isError = false;
                }
            }else{
                isError = true;
                errorMsg = 'File Size can not be more than 1 MB';
                //ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR, 'File Size can not be more than 1 MB'));
                imageBody = null;
                return;
            }
        }
    }

 

I have a serious problem that I cannot figure out. I am new to Salesforce so bear with me.
In the Sandbox, every single Class and Trigger is above 75 percent. Total coverage in Sandbox is 88 percent.
In production Total coverage is 86 percent.

I am unable to deploy *anything* from the sandbox to Production. (this includes a completely empty class).
When trying to deploy to production, all it says is ", Details: Average Test coverage across all Apex Classes and Triggers is 56%, at least 75% test coverage required".

I have absolutely no idea what this means because Sandbox is at 88 percent and Production is at 86 percent when looking at the Developers Console.

Please help. I need whatever ideas one can give. And as I said, it's not releated to any specific thing in what I am deploying. I can't deploy an empty class...

Is there a way to remove some of the Apex Tests within Production? (Because I certainly can't add any... I've been trying to add updated test classes with higher coverage in the Sandbox)

Okay... So I'm very new to Salesforce. And I'm trying to deploy 1 package that has 86 percent coverage in the Sandbox.

But when I go to deploy it in the live system, it is telling me
" Details: Average test coverage across all Apex Classes and Triggers is 55%, at least 75% test coverage is required."

However... when I go to the Develop section and look at the Manage Your Apex Classes., I do the Estimate Code Coverage... and it is listing as 81 percent.

What on earth is the problem? And how do I go about fixing it? 

I've cleared all the data, and re-run all the tests... but no go... and I'm seriously stumped. I can't find anything online that could help me.

I am new to Apex development, and am trying to figure out how to get past the !lead.isConverted part of my Trigger in the Test case.  The test case is only making it to the IF Statement of the Trigger.

Thank you in advance for your help.
trigger LeadConvertVerified on Lead (after Update) {
string convertStatus = 'Closed - Converted';
List<Database.LeadConvert> leadConverts = new List<Database.LeadConvert>();
for (Lead lead: Trigger.new) {
   if (!lead.isConverted && lead.Verified__c == True){
    Database.LeadConvert lc = new Database.LeadConvert();
    lc.setLeadId(lead.Id);
    lc.setAccountId(lead.Organization__c);
    lc.setDoNotCreateOpportunity(TRUE);
    lc.ConvertedStatus= convertStatus;
    leadConverts.add(lc);
        }
    }
if (!leadConverts.isEmpty()) {
List<Database.LeadConvertResult> lcr = Database.convertLead(leadConverts);
}
}

@istest
private class LeadConversionTriggerTestClass {

Static testMethod void LeadConvertTriggerTestClass() {
//Test Against Verified Lead
  Lead l1 = New Lead();
   l1.IsConverted = False;
   l1.FirstName = 'TestOne';
  l1.LastName = 'Testing';
  l1.Organization__c = '001L000000TSsoD';
  l1.Email = 'testone@testing.com';
  l1.Company = 'Individual';
  l1.Verified__C = True;
  insert l1;
    Database.LeadConvert lc = new database.LeadConvert();
         lc.setLeadId(l1.Id);
         LeadStatus convertStatus = [SELECT Id, MasterLabel FROM LeadStatus WHERE IsConverted=true LIMIT 1];
         lc.setConvertedStatus(convertStatus.MasterLabel);
         Database.LeadConvertResult lcr = Database.convertLead(lc);
    
//Test Against Un Verified Lead
Lead l2 = New Lead();
    l2.IsConverted = False;
  l2.FirstName = 'TestOne';
  l2.LastName = 'Testing';
  l2.Organization__c = '001L000000TSsoD';
  l2.Email = 'testone@testing.com';
  l2.Company = 'Individual';
  l2.Verified__C = False;
  insert l2;    
    Database.LeadConvert lc2 = new database.LeadConvert();
         lc.setLeadId(l2.Id);
         LeadStatus convertStatus2 = [SELECT Id, MasterLabel FROM LeadStatus WHERE IsConverted=true LIMIT 1];
         lc.setConvertedStatus(convertStatus2.MasterLabel);
         Database.LeadConvertResult lcr2 = Database.convertLead(lc);
  }
  }
Okay, I've been going crazy with the Governor limits on the queries for SF. I'm not a Salesforce Developer (I'm a C# Developer for Microsoft Dynamics) and this is really getting on my nerves, as I have no idea what is wrong. I have no SOQL queries within the loops, and the LeadConvert is the one that is causing the problems, and it doesn't even have an SOQL query in it.


I have a series of 2 triggers in order to accomplish the following:
1. First trigger goes through and matches the lead against a custom entity, marks it as verified(if there is a match) and updates another field with data from the Custom Entity. - this works, and seems to work on the mass upload. UNLESS -
2. Second Trigger does the Auto Lead Convert to Contact when the Verified field is marked. . Which works just fine individually. But not on a bulk import. When it is used on a Bulk import (in addition to the First trigger). It gives me the Too many SOQL Queries, and the error is popping up on the Second Trigger. Which seems strange, because there is no SOQL query on that trigger.





Here are the two triggers.Trigger 1.
trigger UpdateVerified on Lead (before insert) {
    List<String> leadEmails = new List<String>();
    Map<String, Member_Verification__c > MVMap = new  Map<String, Member_Verification__c >();

    for(Lead lead:Trigger.new){
        leadEmails.add(lead.Email);
        leadEmails.add(lead.Verification__c);
        leadEmails.add(lead.Verification1__c);
        leadEmails.add(lead.Verification2__c);
        leadEmails.add(lead.Verification3__c);
    }
    for(Member_Verification__c member :[SELECT Id, Primary_Email__c, Verification__c, Verification1__c, Verification2__c, Verification3__c,TFA_Salesforce_ID__C FROM Member_Verification__c
                                        WHERE (Primary_Email__c != null and Primary_Email__c IN :leadEmails) or (Verification__c IN :leadEmails)
                                       or (Verification1__c IN :leadEmails) or (Verification2__c IN :leadEmails) or (Verification3__c IN :leadEmails)]
       
       ){
        MVmap.put(member.Primary_Email__c , member);
           MVmap.put(member.Verification__c , member);
           MVmap.put(member.Verification1__c , member);
           MVmap.put(member.Verification2__c , member);
           MVmap.put(member.Verification3__c , member);
       
    }
    
    for(Lead leadObj:Trigger.new){
        if(MVmap.ContainsKey(leadObj.Email) || MVmap.ContainsKey(leadObj.Verification__c) || MVmap.ContainsKey(leadObj.Verification1__c) || MVmap.ContainsKey(leadObj.Verification2__c) || MVmap.ContainsKey(leadObj.Verification3__c)){
           
            If (MVmap.get(leadObj.Email) != Null){
                leadObj.TFA_Salesforce_ID__c = MVmap.get(leadObj.Email).TFA_Salesforce_ID__C ;}
           If (MVmap.get(leadObj.Verification__c) != Null){
                leadObj.TFA_Salesforce_ID__c = MVmap.get(leadObj.Verification__c).TFA_Salesforce_ID__C ;}
           If (MVmap.get(leadObj.Verification1__c) != Null){
                leadObj.TFA_Salesforce_ID__c = MVmap.get(leadObj.Verification1__c).TFA_Salesforce_ID__C ;}
            If (MVmap.get(leadObj.Verification2__c) != Null){
                leadObj.TFA_Salesforce_ID__c = MVmap.get(leadObj.Verification2__c).TFA_Salesforce_ID__C ;}
           If (MVmap.get(leadObj.Verification3__c) != Null){
                leadObj.TFA_Salesforce_ID__c = MVmap.get(leadObj.Verification3__c).TFA_Salesforce_ID__C ;}
            
            LeadObj.Verified__c = True;
        }

        }
}

Trigger 2. The LeadConvert Trigger
trigger LeadConvertVerified on Lead (after Update) {
 
 
string convertStatus = 'Closed - Converted';
    
List<Database.LeadConvert> leadConverts = new List<Database.LeadConvert>();


for (Lead lead: Trigger.new) {
    
   if (!lead.isConverted && lead.Verified__c == True){
            
    Database.LeadConvert lc = new Database.LeadConvert();
    
    lc.setLeadId(lead.Id);
    lc.setAccountId(lead.Organization__c);
    lc.setDoNotCreateOpportunity(TRUE);
    lc.ConvertedStatus= convertStatus;
    
    leadConverts.add(lc);

        }
    }
        
if (!leadConverts.isEmpty()) {
List<Database.LeadConvertResult> lcr = Database.convertLead(leadConverts);
}

        
}

Now - I am getting the following information from the e-mail. Is it possible that the problem is actually with the SFSSSDupeCatcher? And if so, how would I get around that?

18:31:44.332|CUMULATIVE_LIMIT_USAGE_END

18:31:46.205 (49205858164)|CODE_UNIT_FINISHED|LeadConvertVerified on Lead trigger event AfterUpdate for [00QL0000004bMfL]
18:31:46.206 (49206269372)|ENTERING_MANAGED_PKG|CloudingoAgent
18:31:46.206 (49206338391)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:8
18:31:46.206 (49206346194)|VARIABLE_SCOPE_BEGIN|[1]|this|CloudingoAgent.LeadUpdatePOSyncTrigger|true|false
18:31:46.209 (49209390280)|VARIABLE_ASSIGNMENT|[1]|this|{}|0x32c3a985
18:31:46.212 (49212962345)|ENTERING_MANAGED_PKG|SFSSDupeCatcher
18:31:46.213 (49213031885)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:8
18:31:46.213 (49213041109)|VARIABLE_SCOPE_BEGIN|[1]|this|SFSSDupeCatcher.SSDupeCatcherLeadTrigger|true|false
18:31:46.217 (49217282692)|VARIABLE_ASSIGNMENT|[1]|this|{}|0x4bae74cc
18:31:46.221 (49221178557)|SOQL_EXECUTE_BEGIN|[594]|Aggregations:0|select Id, SFSSDupeCatcher__Lead__c from Potential_Duplicate__c where Lead__r.Id IN :tmpVar1
18:31:46.228 (49228156565)|FATAL_ERROR|System.LimitException: SFSSDupeCatcher:Too many SOQL queries: 101

(SFSSDupeCatcher)
I've been trying to figure out how to get a value from a  Map and insert it into a lead. Someone from here was very helpful, and wrote some code. But when I try to save it. I get the above error... I have narrowed down where the error occurs. But I can't figure out why it is giving me this error.

Any help would be greatly appreciated. The part below that is bolded is (I believe) where the error is coming from. Because when I remove those lines, I am allowed to save the trigger.

  trigger UpdateVerifyLead on Lead (before insert, before update) {
      List<String> leadEmails = new List<String>();
      Map<String, Member_Verification__c > PrimaryEmailMemberVerificationMap = new  Map<String, Member_Verification__c >();
       
      for(Lead lead:Trigger.new){
          leadEmails.add(lead.Email);
      }
      for(Member_Verification__c member :[SELECT Id, Primary_Email__c,TFA_Salesforce_ID__C FROM Member_Verification__c WHERE Primary_Email__c != null and Primary_Email__c IN :leadEmails]){
          PrimaryEmailMemberVerificationMap.put(member.Primary_Email__c , member);   
      }
      
      for(Lead leadObj:Trigger.new){
          if(PrimaryEmailMemberVerificationMap.ContainsKey(leadObj.Email)){
              lead.TFA_Salesforce_ID__c = PrimaryEmailMemberVerificationMap.get(leadObj.Email).TFA_Salesforce_ID__C ;
              lead.Verified__c = True;
          }

      }
  }
I asked this once before, and I said I had it. But unforunately it wasn't properly bulkified, so I ended up with the field for every lead being populated with the same information, which shouldn't happen.
So below is my code... I'm trying to get the Value of the field
memberVerification.add(mv.TFA_Salesforce_ID__c);
so that I can update the lead with it. (it is querying the entity Member_Verification__c and matching on e-mail to retrieve what the value should be)

Any help would be appreciated. The way it is right now, it only ever grabs one value and tries to put it in every lead that is inserted during an import of leads)

List<Member_Verification__c> verified = [
        SELECT
            Id, Verification__c ,TFA_Salesforce_ID__C
        FROM
            Member_Verification__c
        WHERE
            Verification__c IN :leadVerification
    ];

Set<String> memberVerification = new Set<String>();
        for(Member_Verification__c mv:verified){
        memberVerification.add(mv.Verification__c);
        memberVerification.add(mv.TFA_Salesforce_ID__c);
            TFAMV = mv.TFA_Salesforce_ID__c;
    }

then later I reference it like this:

            {
                  
                lead.TFA_Salesforce_ID__c = TFAME ;
                lead.Verified__c = True;
                }
Help: First exception on row 1; first error: DUPLICATE_VALUE, duplicate value found:This is pretty much driving me crazy tonight. I have a Trigger that converts leads to Contacts based on criteria in another entity.

Below is the Lead Convert, which is failing with
LeadConvertVerified: execution of AfterInsert

caused by: System.DmlException: ConvertLead failed. First exception on row 1; first error: DUPLICATE_VALUE, duplicate value found: []

Trigger.LeadConvertVerified: line 30, column 1





The only thing is... I hve another trigger that is happening on "before insert". But it is working fine. The failure is happening during the conversion process. I have tried changing this to After Update.. but then it never runs, because nothing is updating it. (even though the Before Insert completes successfuly.)


If I change the below to "After Update" it will work when I manually update the lead. But I need it to convert during the bulk upload.


I have no idea what is happening and have spent too much time banging my head against the wall.


1. I am only loading 5 records as a test.
2. I have verified that the leads do not contain duplicate data for Organization__c or Company(Account).
4. There is no duplicate e-mail, etc...
5. Contacts with the same e-mails as the leads do not exist. 


Any help would be appreciated.


trigger LeadConvertVerified on Lead (after Insert) {
 
 
    LeadStatus convertStatus = [
        select MasterLabel
        from LeadStatus
        where IsConverted = true
        limit 1
        ];
List<Database.LeadConvert> leadConverts = new List<Database.LeadConvert>();


    for (Lead lead: Trigger.new) {
    
   if (!lead.isConverted && lead.Verified__c == True){
            
    Database.LeadConvert lc = new Database.LeadConvert();
    
    lc.setLeadId(lead.Id);
    lc.setAccountId(lead.Organization__c);
    lc.setDoNotCreateOpportunity(TRUE);
    lc.setConvertedStatus(convertStatus.MasterLabel);
    
    leadConverts.add(lc);

        }
    }
        
if (!leadConverts.isEmpty()) {
List<Database.LeadConvertResult> lcr = Database.convertLead(leadConverts);
}

        
}
 

This seems like a dumb question. So dumb, in fact that I'm having trouble finding the answer to it. To preface. I am not an Apex Developer(I'm a C# guy). I've just been helping out a friend get some stuff done. I've pretty much taken care of all the hardest parts of the code, but this last one is baffling me.

I need to update a field on the Lead record from the results of a SOQL query to a custom entity.

The problem is, I have no idea how to retrieve anything from the query. For most of my coding to now, I've used the List<> to get things to match up right for the rest of the code. But I can't seem to get that field value out of it. Here is the list. Any help... from anyone. (even if it is just to point me in the right direction) would be very helpful. Thanks.
(I need the value in the TFA_Salesforce_ID__c field on the Member_Verification__c Entity as a string value)

   list<String> leadEmails= new list<String>();
    for (Lead lead:Trigger.new) {
        leadEmails.add(lead.Email);
    }
    
    list<Member_Verification__c> emails = [
        Select  id, Primary_Email__c,TFA_Salesforce_ID__c
        from Member_Verification__c
        where (Primary_Email__c != null and Primary_Email__c in :leadEmails)
    ];

 

This was working a couple of weeks ago, and I added some code to deal with some duplication control. And now it's not even populating the Map during the test, so it's only got 19 percent coverage.
First is the Trigger... When testing against the class (in the next post)..... the MVmap.put commands are all red. So it's never getting to that portion of the code. And I can't for the life of me figure out why. It was working. Now it isn't.

trigger UpdateLeadVerification on Lead (before insert, before update) {
    List<String> leadEmails = new List<String>();
    Map<String, Member_Verification__c > MVMap = new  Map<String, Member_Verification__c >();

    for(Lead lead:Trigger.new){
        leadEmails.add(lead.Email);
        leadEmails.add(lead.Verification__c);
        leadEmails.add(lead.Verification1__c);
        leadEmails.add(lead.Verification2__c);
        leadEmails.add(lead.Verification3__c);
    }
    for(Member_Verification__c member :[SELECT Id, Primary_Email__c, Verification__c, Verification1__c, Verification2__c, Verification3__c,TFA_Salesforce_ID__C, Lee_Member__c FROM Member_Verification__c
                                        WHERE ((Primary_Email__c != null and Primary_Email__c IN :leadEmails) or (Verification__c IN :leadEmails)
                                       or (Verification1__c IN :leadEmails) or (Verification2__c IN :leadEmails) or (Verification3__c IN :leadEmails))]
       
       ){
        MVmap.put(member.Primary_email__c , member);
           MVmap.put(member.Verification__c , member);
           MVmap.put(member.Verification1__c , member);
           MVmap.put(member.Verification2__c , member);
           MVmap.put(member.Verification3__c , member);

          
    }
    
    for(Lead leadObj:Trigger.new){
        if(MVmap.ContainsKey(leadObj.Email) || MVmap.ContainsKey(leadObj.Verification__c) || MVmap.ContainsKey(leadObj.Verification1__c) || MVmap.ContainsKey(leadObj.Verification2__c) || MVmap.ContainsKey(leadObj.Verification3__c)){
            If (MVmap.get(leadObj.Email) != Null){
                If(MVmap.get(LeadObj.Email).Lee_member__c != True){
                leadObj.TFA_Salesforce_ID__c = MVmap.get(leadObj.Email).TFA_Salesforce_ID__C ;
                leadObj.Member_Verification_Record__c = MVmap.get(leadObj.Email).id;
                LeadObj.Verified__c = True;
                MVmap.get(leadObj.Email).Lee_Member__c = true;
                update MVmap.get(leadObj.Email);
            } else
                If(MVmap.get(LeadObj.Email).Lee_member__c != False){
                leadObj.Member_Verification_Record__c = MVmap.get(leadObj.Email).id;    
                LeadObj.status = 'Closed - Duplicate';
                }
                    
            }
           If (MVmap.get(leadObj.Verification__c) != Null){
               If(MVmap.get(LeadObj.Verification__c).Lee_member__c != True){
                leadObj.TFA_Salesforce_ID__c = MVmap.get(leadObj.Verification__c).TFA_Salesforce_ID__C ;
                leadObj.Member_Verification_Record__c = MVmap.get(leadObj.Verification__c).id;
                LeadObj.Verified__c = True;
                MVmap.get(leadObj.Verification__c).Lee_Member__c = true;
                update MVmap.get(leadObj.Verification__c);
               } else
               If(MVmap.get(LeadObj.Verification__c).Lee_member__c != False){
                   leadObj.Member_Verification_Record__c = MVmap.get(leadObj.Verification__c).id;
                  LeadObj.status = 'Closed - Duplicate';  
               }
               }
                
           If (MVmap.get(leadObj.Verification1__c) != Null){
               If(MVmap.get(LeadObj.Verification1__c).Lee_member__c != True){
               leadObj.TFA_Salesforce_ID__c = MVmap.get(leadObj.Verification1__c).TFA_Salesforce_ID__C ;
                leadObj.Member_Verification_Record__c = MVmap.get(leadObj.Verification1__c).id;
                   LeadObj.Verified__c = True;
                MVmap.get(leadObj.Verification1__c).Lee_Member__c = true;
                update MVmap.get(leadObj.Verification1__c);
                           } else
               If(MVmap.get(LeadObj.Verification1__c).Lee_member__c != False){
                   leadObj.Member_Verification_Record__c = MVmap.get(leadObj.Verification1__c).id;
                  LeadObj.status = 'Closed - Duplicate';  
               }
           }
            
            If (MVmap.get(leadObj.Verification2__c) != Null){
                If(MVmap.get(LeadObj.Verification2__c).Lee_member__c != True){
                leadObj.TFA_Salesforce_ID__c = MVmap.get(leadObj.Verification2__c).TFA_Salesforce_ID__C ;
                leadObj.Member_Verification_Record__c = MVmap.get(leadObj.Verification2__c).id;
                    LeadObj.Verified__c = True;
                MVmap.get(leadObj.Verification2__c).Lee_Member__c = true;
                update MVmap.get(leadObj.Verification2__c);
                
                } else
               If(MVmap.get(LeadObj.Verification2__c).Lee_member__c != False){
                   leadObj.Member_Verification_Record__c = MVmap.get(leadObj.Verification2__c).id;
                  LeadObj.status = 'Closed - Duplicate';  
               }
           }
            
            If (MVmap.get(leadObj.Verification3__c) != Null){
                If(MVmap.get(LeadObj.Verification3__c).Lee_member__c != True){
                leadObj.TFA_Salesforce_ID__c = MVmap.get(leadObj.Verification3__c).TFA_Salesforce_ID__C ;
                leadObj.Member_Verification_Record__c = MVmap.get(leadObj.Verification3__c).id;
                LeadObj.Verified__c = True;
                MVmap.get(leadObj.Verification3__c).Lee_Member__c = true;
                update MVmap.get(leadObj.Verification3__c);
                
                } else
               If(MVmap.get(LeadObj.Verification3__c).Lee_member__c != False){
                   leadObj.Member_Verification_Record__c = MVmap.get(leadObj.Verification3__c).id;
                  LeadObj.status = 'Closed - Duplicate';  
               }
           }
            
            
        }

        }

}
Can't get any coverage on this, and can't figure out why. Both this class and the test cases were written by another developer (who is not available anymore to ask questions of). But I can't get any coverage on this no matter what I try. Any help is greatly appreciated.

Going to have to put this code up in parts as it is too large.
public without sharing class MyProfileController {
    public String fname{set;get;}
    public String lname{set;get;}
    public String fullmiddelname{set;get;}
    public String pemail{set;get;}
    public String semail{set;get;}
    public String mobile{set;get;}
    public String home{set;get;}
    public String work{set;get;}
    public String street{set;get;}
    public String city{set;get;}
    public String state{set;get;}
    public String zip{set;get;}
    public String country{set;get;}
    public String facebook{set;get;}
    public String twitter{set;get;}
    public String linkedin{set;get;}
    public String birthdate{set;get;}
    public String gender{set;get;}
    public String race{set;get;}
    public String profession{set;get;}
    public String pinterest{set;get;}
    public String ainterest{set;get;}    
    public String ointerest{set;get;}    
    public String corpregion{set;get;}
    public String alumniregion{set;get;}
    public String corpregionView{set;get;}
    public String alumniregionView{set;get;}
    public String corpYear{set;get;}
    public boolean HasOptedOutOfEmail{get;set;}
    public boolean DoNotCall{get;set;}
    public boolean memberoptout{set;get;}
    public List<SelectOption> corpRegions{get;set;}
    public List<SelectOption> advocacyInterests{get;set;}
    public List<SelectOption> policyInterests{get;set;}
    public List<SelectOption> organizingInterests{get;set;}
    public List<SelectOption> ethnicityOntions{get;set;}
    public blob imagebody{set;get;}
    public string imageName{set;get;}
    public string imagesrc{set;get;}
    public string imagesrc1{set;get;}
    public boolean isEditable{set;get;}
    public boolean registered{set;get;}
    public String leadership{set;get;}
    public List<SelectOption> leaderships{get;set;}
    public List<SelectOption> volunteerInterests{get;set;}
    public String volunteerInterest{set;get;}
    List<Region__c> corpRegionsList;
    List<Region__c> alumniRegionsList;
    Map<String,Region__c> regionsMap;
    String oldZip;
    String contactId;
    List<Attachment> att;
    public Contact con{set;get;}
    Attachment img;
    Contact_Picture__c contactImage;
    public LEE_Campaign__c leecamp{set;get;}
    public boolean showErr{set;get;}
    List<Region_ZipCode__c> zipcodes;
    List<Region_Membership__c> regionMembers;
    Decimal filesize;
    public boolean isError{set;get;}
    public String errorMsg{set;get;}
    public string title{set;get;}
    public string employer{set;get;}
    public MyProfileController(){
        isError = false;
        regionsMap = new Map<String,Region__c>();
        leecamp = new LEE_Campaign__c();
        showErr = false;
        User loggedUser = [SELECT id,ContactID from User WHERE Id=: userInfo.getUserId()];
        //contactId = ApexPages.currentPage().getParameters().get('id');
        contactId = loggedUser.ContactId;
       // contactId = '003M000000Dp9z9';
        isEditable = false;
        policyInterests =  new List<SelectOption>();
        advocacyInterests = new List<SelectOption>();
        organizingInterests = new List<SelectOption>();
        ethnicityOntions = new List<SelectOption>();
        leaderships = new List<SelectOption>();
        volunteerInterests  = new List<SelectOption>();
        //Populate Advocacy Interest Picklist
        Schema.DescribeFieldResult fieldResult = Contact.Advocacy_Interest__c.getDescribe();
        List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();
        for(Schema.PicklistEntry f : ple){
            advocacyInterests.add(new SelectOption(f.getLabel(), f.getValue()));
        }
        //Populate Policy Interest Picklist
        fieldResult =  Contact.Policy_Interest__c.getDescribe();
        ple = fieldResult.getPicklistValues();
        for(Schema.PicklistEntry f : ple){
            policyInterests.add(new SelectOption(f.getLabel(), f.getValue()));
        }
        
        //Populate Organizing Interest Picklist
        fieldResult =  Contact.Organizing_Interest__c.getDescribe();
        ple = fieldResult.getPicklistValues();
        for(Schema.PicklistEntry f : ple){
            organizingInterests.add(new SelectOption(f.getLabel(), f.getValue()));
        }
        //Populate Ethnicity Picklist
        fieldResult =  Contact.Ethnicity__c.getDescribe();
        ple = fieldResult.getPicklistValues();
        for(Schema.PicklistEntry f : ple){
            ethnicityOntions.add(new SelectOption(f.getLabel(), f.getValue()));
        }
        
        //Populate Public Leadership Aspirations Picklist
        fieldResult =  Contact.Public_Leadership_Aspirations__c.getDescribe();
        ple = fieldResult.getPicklistValues();
        for(Schema.PicklistEntry f : ple){
            leaderships.add(new SelectOption(f.getLabel(), f.getValue()));
        }
        //Populate Volunteer Interests Picklist
        fieldResult =  Contact.Volunteer_Interests__c.getDescribe();
        ple = fieldResult.getPicklistValues();
        for(Schema.PicklistEntry f : ple){
            volunteerInterests.add(new SelectOption(f.getLabel(), f.getValue()));
        }
        
        //contactId = ApexPages.currentPage().getParameters().get('contactId');
        corpRegions = new List<SelectOption>();
        corpRegionsList = [SELECT id,Name from Region__c];
        //Populate Corp Region and Amumni Region Picklist
        if(corpRegionsList != null && corpRegionsList.size() > 0){
            for(Region__c r: corpRegionsList){
                corpRegions.add(new SelectOption(r.Id,r.Name));
                regionsMap.put(r.Name,r);
            }
        }else{
            corpRegions.add(new SelectOption('',''));
        }
        
        if(contactId != null && contactId.trim().length() > 0){
            con = [Select c.Twitter__c,  c.Secondary_Email__c,
                        c.Ethnicity__c, c.Profession__c, c.Policy_Interest__c, Volunteer_Interests__c,
                        c.Phone,  c.Organizing_Interest__c, c.Name, c.MobilePhone, c.Member_Stage__c,
                        c.MailingStreet, c.MailingState, c.MailingPostalCode, c.MailingCountry, c.MailingCity, c.DoNotCall,
                        c.Linked_In__c, c.LeadSource, c.LastName,  c.Id, c.HomePhone, Registered_to_Vote__c,
                        c.Gender__c, c.Full_Middle_Name__c, c.FirstName, c.Fax, c.Facebook__c, Public_Leadership_Aspirations__c,
                        c.Email,c.Corps_Year__c, c.Corp_Region__c, c.Birthdate, c.Alumni_Region__c, c.Advocacy_Interest__c, c.HasOptedOutOfEmail,
                        c.Employee_Title__c,c.Employment_Organization__c
                    From Contact c
                    WHERE Id=: contactId];
                    
            if(con != null){
                fname = con.FirstName;
                lname = con.LastName;
                fullmiddelName = con.Full_Middle_Name__c;
                home = con.HomePhone;
                mobile = con.MobilePhone;
                work = con.Phone;
                pemail = con.Email;
                semail = con.Secondary_Email__c;
                facebook = con.Facebook__c;
                twitter = con.Twitter__c;
                linkedin = con.Linked_In__c;
                street = con.MailingStreet;
                city = con.MailingCity;
                state = con.MailingState;
                zip = con.MailingPostalCode;
                oldZip = zip;
                country = con.MailingCountry;
                title = con.Employee_Title__c;
                employer = con.Employment_Organization__c;
                //birthdate = String.valueOf(con.BirthDate);
                race = con.Ethnicity__c;
                profession = con.Profession__c;
                gender = con.Gender__c;
                pinterest = con.Policy_Interest__c;
                ainterest = con.Advocacy_Interest__c;
                ointerest = con.Organizing_Interest__c;
                corpregion = con.Corp_Region__c;
                alumniregion = con.Alumni_Region__c;
                if(con.HasOptedOutOfEmail != null)
                    HasOptedOutOfEmail = con.HasOptedOutOfEmail;
                else
                    HasOptedOutOfEmail = false;
                if(con.DoNotCall != null)
                    DoNotCall = con.DoNotCall;
                else
                    DoNotCall = false;
                for(SelectOption so:corpRegions){
                    if(so.getValue() == corpregion){
                        corpregionView = so.getLabel();
                    }
                }
                
                for(SelectOption so:corpRegions){
                    if(so.getValue() == alumniregion){
                        alumniregionView = so.getLabel();
                    }
                }
                corpYear = con.Corps_Year__c;
                if(con.Member_Stage__c == 'Deactivated'){
                    memberoptout = true;
                }else{
                    memberoptout = false;
                }
                registered = con.Registered_to_Vote__c;
                String str = con.Public_Leadership_Aspirations__c;
                
                /*str = str.replaceAll(';',',');
                str ='['+str + ']';*/
                leadership = str;
                System.Debug('@@@@@@@@Value'+leadership);
                volunteerInterest = con.Volunteer_Interests__c;
                
                List<Contact_Picture__c> contactImages = [SELECT id,Contact__c from Contact_Picture__c WHERE Contact__c =: con.id];
                if(contactImages != null && contactImages.size() >0){
                    contactImage = contactImages[0];
                    att = [SELECT id,Name from Attachment WHERE parentId =: contactImage.Id Order By CreatedDate Desc LIMIT 1];
                    if(att != null && att.size() > 0){
                        System.Debug('######Attachment ID'+att[0].id);
                        //imagebody = att[0].body;
                       /* imagesrc1 = String.valueOf(imagebody);
                        System.Debug('######Image Body'+imagesrc1);*/
                        //imageName = att[0].Name;
                        imagesrc = '/servlet/servlet.FileDownload?file='+att[0].id;
                    }
                }
                
            }else{
                con = new Contact();
            }
        }
    }
    public void upload(){       
        if(imageName != null && imageBody != null){
            filesize = imageBody.size();
            filesize = filesize /(1024*1024);
            if(filesize <= 1){
                if(con != null && con.id != null){
                    if( contactImage != null && contactImage.Contact__c != null){
                        img = new Attachment(Name = imageName,Body=imageBody,ParentId = contactImage.id);
                        insert img;
                    }else{
                        contactImage = new  Contact_Picture__c(Contact__c = con.Id);
                        insert contactImage;
                        img = new Attachment(Name = imageName,Body=imageBody,ParentId = contactImage.id);
                        insert img;
                    }
                    imagesrc = '/servlet/servlet.FileDownload?file='+img.id;
                    imageBody = null;
                    img = null;
                    isError = false;
                }
            }else{
                isError = true;
                errorMsg = 'File Size can not be more than 1 MB';
                //ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR, 'File Size can not be more than 1 MB'));
                imageBody = null;
                return;
            }
        }
    }

 

I have a serious problem that I cannot figure out. I am new to Salesforce so bear with me.
In the Sandbox, every single Class and Trigger is above 75 percent. Total coverage in Sandbox is 88 percent.
In production Total coverage is 86 percent.

I am unable to deploy *anything* from the sandbox to Production. (this includes a completely empty class).
When trying to deploy to production, all it says is ", Details: Average Test coverage across all Apex Classes and Triggers is 56%, at least 75% test coverage required".

I have absolutely no idea what this means because Sandbox is at 88 percent and Production is at 86 percent when looking at the Developers Console.

Please help. I need whatever ideas one can give. And as I said, it's not releated to any specific thing in what I am deploying. I can't deploy an empty class...

Is there a way to remove some of the Apex Tests within Production? (Because I certainly can't add any... I've been trying to add updated test classes with higher coverage in the Sandbox)

Okay... So I'm very new to Salesforce. And I'm trying to deploy 1 package that has 86 percent coverage in the Sandbox.

But when I go to deploy it in the live system, it is telling me
" Details: Average test coverage across all Apex Classes and Triggers is 55%, at least 75% test coverage is required."

However... when I go to the Develop section and look at the Manage Your Apex Classes., I do the Estimate Code Coverage... and it is listing as 81 percent.

What on earth is the problem? And how do I go about fixing it? 

I've cleared all the data, and re-run all the tests... but no go... and I'm seriously stumped. I can't find anything online that could help me.

I am new to Apex development, and am trying to figure out how to get past the !lead.isConverted part of my Trigger in the Test case.  The test case is only making it to the IF Statement of the Trigger.

Thank you in advance for your help.
trigger LeadConvertVerified on Lead (after Update) {
string convertStatus = 'Closed - Converted';
List<Database.LeadConvert> leadConverts = new List<Database.LeadConvert>();
for (Lead lead: Trigger.new) {
   if (!lead.isConverted && lead.Verified__c == True){
    Database.LeadConvert lc = new Database.LeadConvert();
    lc.setLeadId(lead.Id);
    lc.setAccountId(lead.Organization__c);
    lc.setDoNotCreateOpportunity(TRUE);
    lc.ConvertedStatus= convertStatus;
    leadConverts.add(lc);
        }
    }
if (!leadConverts.isEmpty()) {
List<Database.LeadConvertResult> lcr = Database.convertLead(leadConverts);
}
}

@istest
private class LeadConversionTriggerTestClass {

Static testMethod void LeadConvertTriggerTestClass() {
//Test Against Verified Lead
  Lead l1 = New Lead();
   l1.IsConverted = False;
   l1.FirstName = 'TestOne';
  l1.LastName = 'Testing';
  l1.Organization__c = '001L000000TSsoD';
  l1.Email = 'testone@testing.com';
  l1.Company = 'Individual';
  l1.Verified__C = True;
  insert l1;
    Database.LeadConvert lc = new database.LeadConvert();
         lc.setLeadId(l1.Id);
         LeadStatus convertStatus = [SELECT Id, MasterLabel FROM LeadStatus WHERE IsConverted=true LIMIT 1];
         lc.setConvertedStatus(convertStatus.MasterLabel);
         Database.LeadConvertResult lcr = Database.convertLead(lc);
    
//Test Against Un Verified Lead
Lead l2 = New Lead();
    l2.IsConverted = False;
  l2.FirstName = 'TestOne';
  l2.LastName = 'Testing';
  l2.Organization__c = '001L000000TSsoD';
  l2.Email = 'testone@testing.com';
  l2.Company = 'Individual';
  l2.Verified__C = False;
  insert l2;    
    Database.LeadConvert lc2 = new database.LeadConvert();
         lc.setLeadId(l2.Id);
         LeadStatus convertStatus2 = [SELECT Id, MasterLabel FROM LeadStatus WHERE IsConverted=true LIMIT 1];
         lc.setConvertedStatus(convertStatus2.MasterLabel);
         Database.LeadConvertResult lcr2 = Database.convertLead(lc);
  }
  }
Okay, I've been going crazy with the Governor limits on the queries for SF. I'm not a Salesforce Developer (I'm a C# Developer for Microsoft Dynamics) and this is really getting on my nerves, as I have no idea what is wrong. I have no SOQL queries within the loops, and the LeadConvert is the one that is causing the problems, and it doesn't even have an SOQL query in it.


I have a series of 2 triggers in order to accomplish the following:
1. First trigger goes through and matches the lead against a custom entity, marks it as verified(if there is a match) and updates another field with data from the Custom Entity. - this works, and seems to work on the mass upload. UNLESS -
2. Second Trigger does the Auto Lead Convert to Contact when the Verified field is marked. . Which works just fine individually. But not on a bulk import. When it is used on a Bulk import (in addition to the First trigger). It gives me the Too many SOQL Queries, and the error is popping up on the Second Trigger. Which seems strange, because there is no SOQL query on that trigger.





Here are the two triggers.Trigger 1.
trigger UpdateVerified on Lead (before insert) {
    List<String> leadEmails = new List<String>();
    Map<String, Member_Verification__c > MVMap = new  Map<String, Member_Verification__c >();

    for(Lead lead:Trigger.new){
        leadEmails.add(lead.Email);
        leadEmails.add(lead.Verification__c);
        leadEmails.add(lead.Verification1__c);
        leadEmails.add(lead.Verification2__c);
        leadEmails.add(lead.Verification3__c);
    }
    for(Member_Verification__c member :[SELECT Id, Primary_Email__c, Verification__c, Verification1__c, Verification2__c, Verification3__c,TFA_Salesforce_ID__C FROM Member_Verification__c
                                        WHERE (Primary_Email__c != null and Primary_Email__c IN :leadEmails) or (Verification__c IN :leadEmails)
                                       or (Verification1__c IN :leadEmails) or (Verification2__c IN :leadEmails) or (Verification3__c IN :leadEmails)]
       
       ){
        MVmap.put(member.Primary_Email__c , member);
           MVmap.put(member.Verification__c , member);
           MVmap.put(member.Verification1__c , member);
           MVmap.put(member.Verification2__c , member);
           MVmap.put(member.Verification3__c , member);
       
    }
    
    for(Lead leadObj:Trigger.new){
        if(MVmap.ContainsKey(leadObj.Email) || MVmap.ContainsKey(leadObj.Verification__c) || MVmap.ContainsKey(leadObj.Verification1__c) || MVmap.ContainsKey(leadObj.Verification2__c) || MVmap.ContainsKey(leadObj.Verification3__c)){
           
            If (MVmap.get(leadObj.Email) != Null){
                leadObj.TFA_Salesforce_ID__c = MVmap.get(leadObj.Email).TFA_Salesforce_ID__C ;}
           If (MVmap.get(leadObj.Verification__c) != Null){
                leadObj.TFA_Salesforce_ID__c = MVmap.get(leadObj.Verification__c).TFA_Salesforce_ID__C ;}
           If (MVmap.get(leadObj.Verification1__c) != Null){
                leadObj.TFA_Salesforce_ID__c = MVmap.get(leadObj.Verification1__c).TFA_Salesforce_ID__C ;}
            If (MVmap.get(leadObj.Verification2__c) != Null){
                leadObj.TFA_Salesforce_ID__c = MVmap.get(leadObj.Verification2__c).TFA_Salesforce_ID__C ;}
           If (MVmap.get(leadObj.Verification3__c) != Null){
                leadObj.TFA_Salesforce_ID__c = MVmap.get(leadObj.Verification3__c).TFA_Salesforce_ID__C ;}
            
            LeadObj.Verified__c = True;
        }

        }
}

Trigger 2. The LeadConvert Trigger
trigger LeadConvertVerified on Lead (after Update) {
 
 
string convertStatus = 'Closed - Converted';
    
List<Database.LeadConvert> leadConverts = new List<Database.LeadConvert>();


for (Lead lead: Trigger.new) {
    
   if (!lead.isConverted && lead.Verified__c == True){
            
    Database.LeadConvert lc = new Database.LeadConvert();
    
    lc.setLeadId(lead.Id);
    lc.setAccountId(lead.Organization__c);
    lc.setDoNotCreateOpportunity(TRUE);
    lc.ConvertedStatus= convertStatus;
    
    leadConverts.add(lc);

        }
    }
        
if (!leadConverts.isEmpty()) {
List<Database.LeadConvertResult> lcr = Database.convertLead(leadConverts);
}

        
}

Now - I am getting the following information from the e-mail. Is it possible that the problem is actually with the SFSSSDupeCatcher? And if so, how would I get around that?

18:31:44.332|CUMULATIVE_LIMIT_USAGE_END

18:31:46.205 (49205858164)|CODE_UNIT_FINISHED|LeadConvertVerified on Lead trigger event AfterUpdate for [00QL0000004bMfL]
18:31:46.206 (49206269372)|ENTERING_MANAGED_PKG|CloudingoAgent
18:31:46.206 (49206338391)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:8
18:31:46.206 (49206346194)|VARIABLE_SCOPE_BEGIN|[1]|this|CloudingoAgent.LeadUpdatePOSyncTrigger|true|false
18:31:46.209 (49209390280)|VARIABLE_ASSIGNMENT|[1]|this|{}|0x32c3a985
18:31:46.212 (49212962345)|ENTERING_MANAGED_PKG|SFSSDupeCatcher
18:31:46.213 (49213031885)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:8
18:31:46.213 (49213041109)|VARIABLE_SCOPE_BEGIN|[1]|this|SFSSDupeCatcher.SSDupeCatcherLeadTrigger|true|false
18:31:46.217 (49217282692)|VARIABLE_ASSIGNMENT|[1]|this|{}|0x4bae74cc
18:31:46.221 (49221178557)|SOQL_EXECUTE_BEGIN|[594]|Aggregations:0|select Id, SFSSDupeCatcher__Lead__c from Potential_Duplicate__c where Lead__r.Id IN :tmpVar1
18:31:46.228 (49228156565)|FATAL_ERROR|System.LimitException: SFSSDupeCatcher:Too many SOQL queries: 101

(SFSSDupeCatcher)