• Stacy Sennott
  • NEWBIE
  • 25 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 7
    Replies
Hi,

I have included the following code in my Web-To-Lead form but it does not seem to be working to input the correct default values I have specified
<input type=hidden name="lead_source" value="Web"> 
<input type=hidden name="company" value="Onassis Foundation (USA)">
<input type=hidden name="00N37000004HPYD" value=true>

The last line refers to a check box with the id code refernenced to return a TRUE value upon Submission of Form.

Here is the link to the test form, which shows these fields to be hidden just above the code for the first visible info in the form.  But when I check in my Salesforce database, the default values are not specified upon Submitting: 
http://www.onassisusa.org/onassis-form-test2.html
Your help is appreciated!
I am a beginner at this, and have a fairly basic Trigger I am using.  It is achieving 94% code coverage (16/17).  When I try to deploy to production it fails with an error message of 0% code coverage.  Not sure how to increase to at least 1%.
Below is both my Trigger code and Apex Class Test code:

TRIGGER CODE:

trigger LeadConvert on Lead (after insert) {
 
    list<database.leadconvert> leadsToConvert = new list<database.leadconvert>();
    Database.LeadConvert lc;
    string convertedStatus = '';
    list<leadstatus> convertStatusList = new list<leadstatus>();
    convertStatusList = [Select Id, MasterLabel
                            from LeadStatus
                            where IsConverted=true limit 1];
    if(convertStatusList.size() > 0){
        convertedStatus = convertStatusList[0].MasterLabel;
    }else{
        convertedStatus = 'Closed - Converted';
    }
     
    for(Lead l : trigger.New){
        if(l.LeadSource == 'Web'){
            //This lead should be converted automatically to a Contact/Account
            lc = new database.LeadConvert();
            lc.setLeadId(l.ID);
            lc.setDoNotCreateOpportunity(true);
            lc.setConvertedStatus(convertedStatus);
            leadsToConvert.add(lc);
        }
    }
     
    list<database.leadconvertresult> lcrList = new list<database.leadconvertresult>();
    lcrList = Database.convertLead(leadsToConvert);
}


APEX CLASS TEST CODE:

@IsTest
public class TestConvertLead {
    static testmethod void convertLead() {
    
        Lead l = new Lead();
        
        l.FirstName = 'Jane';
        l.LastName = 'Doe';
        l.Company = 'Onassis Foundation (USA)';
        l.Email = 'senvas@aol.com';
        l.LeadSource = 'Web';
        
        insert l;
    }
}
Hi,

I have included the following code in my Web-To-Lead form but it does not seem to be working to input the correct default values I have specified
<input type=hidden name="lead_source" value="Web"> 
<input type=hidden name="company" value="Onassis Foundation (USA)">
<input type=hidden name="00N37000004HPYD" value=true>

The last line refers to a check box with the id code refernenced to return a TRUE value upon Submission of Form.

Here is the link to the test form, which shows these fields to be hidden just above the code for the first visible info in the form.  But when I check in my Salesforce database, the default values are not specified upon Submitting: 
http://www.onassisusa.org/onassis-form-test2.html
Your help is appreciated!
I am a beginner at this, and have a fairly basic Trigger I am using.  It is achieving 94% code coverage (16/17).  When I try to deploy to production it fails with an error message of 0% code coverage.  Not sure how to increase to at least 1%.
Below is both my Trigger code and Apex Class Test code:

TRIGGER CODE:

trigger LeadConvert on Lead (after insert) {
 
    list<database.leadconvert> leadsToConvert = new list<database.leadconvert>();
    Database.LeadConvert lc;
    string convertedStatus = '';
    list<leadstatus> convertStatusList = new list<leadstatus>();
    convertStatusList = [Select Id, MasterLabel
                            from LeadStatus
                            where IsConverted=true limit 1];
    if(convertStatusList.size() > 0){
        convertedStatus = convertStatusList[0].MasterLabel;
    }else{
        convertedStatus = 'Closed - Converted';
    }
     
    for(Lead l : trigger.New){
        if(l.LeadSource == 'Web'){
            //This lead should be converted automatically to a Contact/Account
            lc = new database.LeadConvert();
            lc.setLeadId(l.ID);
            lc.setDoNotCreateOpportunity(true);
            lc.setConvertedStatus(convertedStatus);
            leadsToConvert.add(lc);
        }
    }
     
    list<database.leadconvertresult> lcrList = new list<database.leadconvertresult>();
    lcrList = Database.convertLead(leadsToConvert);
}


APEX CLASS TEST CODE:

@IsTest
public class TestConvertLead {
    static testmethod void convertLead() {
    
        Lead l = new Lead();
        
        l.FirstName = 'Jane';
        l.LastName = 'Doe';
        l.Company = 'Onassis Foundation (USA)';
        l.Email = 'senvas@aol.com';
        l.LeadSource = 'Web';
        
        insert l;
    }
}