• deryckj
  • NEWBIE
  • 0 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 8
    Replies

Please point me in the right direction.  I've spent the past two days trying to sort through examples that might apply and am just confusing myself more and more....I've run out of time and must get this code deployed to production.  Here's a sample - any help greatly appreciated:

 

This is one of six classes and six triggers that I have to get coverage on...not sure of the best way to proceed.  Thanks in advance!

 

publicwithsharingclass Lead_Creation {

 

    public String searchTerm {get; set;}

    public List<Lead> returnedLeads {get; set;}

    public Boolean isNewLead {get; set;}

    public String SelectedCampaignId {get; set;}

    public String SelectedCampaignName {get; set;}

      

    private Account SelectedProject;

    public Lead currentLead {get; set;}

    

    

    public String SelectedExtension {get; set;}

    public List<SelectOption> getExtensionsOptions()

    {

        SelectedCampaignId = '';

        SelectedCampaignName = '';

        currentLead.Ad_Type__c  = null;

        List<SelectOption> options = new List<SelectOption>();

        options.add(new SelectOption('None','--None--'));

        SelectedExtension = options[0].getLabel();

        for(Campaign c : [SELECT Project_Code__c, Extension__c, Media_Source__r.Name

                          Ad_Size__c, Ad_Type__c FROM Campaign WHERE Project__c =: currentLead.Project_Site__c AND RecordType.Name != 'Parent'])

        {

            string AdType = (c.Ad_Type__c != null ? c.Ad_Type__c : '');

            string AdSize = (c.Ad_Size__c != null ? c.Ad_Size__c : '');

            String ext = c.Project_Code__c+'-'+string.valueof(c.Extension__c)+'-'+c.Media_Source__r.Name+'-'+AdType+'-'+AdSize ;

            options.add(new SelectOption(ext,ext));

        }

        

        if(options.size() == 2)

        {

            SelectedExtension = options[1].getLabel(); 

            populateAdvertizingInfo();

        }

        

        return options;

    }

 

    {

        isNewLead = false;

        

    }

    public Lead_Creation(ApexPages.StandardController controller) {

        currentLead = (Lead)controller.getRecord();

        currentLead.Status = 'Unassigned';

        currentLead.LastName = ' ';

        currentLead.ownerid = UserInfo.getUserId();

    }

    

    public void fetchLeads()

    {

        returnedLeads  = new List<Lead>();

        

        String searchCriteria = '%'+searchTerm+'%';

        

        returnedLeads  = [Select Id, Name, Email, Phone, City, Street, State, Country, Status, Owner.Name, Ownerid

                            FROM Lead 

                            WHERE Email Like : searchCriteria OR Phone Like : searchCriteria  OR Name Like : searchCriteria  Limit 1000];

                            

        if(returnedLeads.isEmpty())

        {

            ApexPages.AddMessage(new ApexPages.Message(ApexPages.Severity.Confirm,'This is a New Lead'));

        }else

        {

            ApexPages.AddMessage(new ApexPages.Message(ApexPages.Severity.Warning,'Similar Leads were found, please verify the list below'));

        }

    }

    

    private Campaign thisCampaign ;

    public void populateAdvertizingInfo()

    {

        List<String> SelectedAdSeries = SelectedExtension.split('-');

        Decimal ext = Decimal.valueof(SelectedAdSeries[1]);

        thisCampaign = [Select Campaign_Fully_Qualified__c, Ad_Type__c, Ad_Size__c, Media_Source__c, Project_Code__c,

                       Type from Campaign where Project__c =: currentLead.Project_site__c AND Extension__c =: ext LIMIT 1];

        system.debug('the campaign '+thisCampaign.id);

        currentLead.Ad_Type__c = thisCampaign.Ad_Type__c;

        currentLead.Ad_Size__c = thisCampaign.Ad_Size__c;

        currentLead.Media_Source__c = thisCampaign.Media_Source__c;

        currentLead.Project_Code__c = thisCampaign.Project_Code__c;

        currentLead.Ad_Series__c = thisCampaign.Campaign_Fully_Qualified__c;

        SelectedCampaignID = thisCampaign.Id;  

        SelectedCampaignName = thisCampaign.Campaign_Fully_Qualified__c;

    }

    

    public void getExtensions()

    {

        getExtensionsOptions();

    }

    

    public PageReference createNewLead()

    {

        isNewLead = true;

 

        return null;

    }

    

    public PageReference saveExt()

    {

        integer err = 0;

        if(currentLead.LastName != null && currentLead.Status != null)

        {

            try{

                currentLead.Extension__c = SelectedExtension;

                insert currentLead;

                

            }catch(Exception e)

            {

                system.debug('the error'+e.getMessage());

                err++;

                return null;

            }

        }else

        {

            if(currentLead.LastName == null)

                currentLead.LastName.addError('This field is required');

            if(currentLead.Status == null)

                currentLead.Status.addError('This field is required');

            return null;

        }

            

        if(err == 0)

        {

            CampaignMember newCM = newCampaignMember(

                                            CampaignId = thisCampaign.id,

                                            LeadId = currentLead.Id,

                                            Status = 'Responded'

                                        );

                

            try{

                insert newCM;

            }catch(Exception e)

            {

                system.debug('the error'+e.getMessage());

            }

            

        }

        

        return new PageReference('/'+currentLead.Id);

    }

 

}

  • September 20, 2013
  • Like
  • 0
Error is in expression '{!populateAdvertizingInfo}' in page lead_creation

 

Class.Lead_Creation.populateAdvertizingInfo: line 88, column 1

---------------------------------

 

Error results on VisualForce page that references the following code on my visualforce page.  What's highlighted in orange is what is failing and the referenced code follows below:

 

<apex:selectListvalue="{!SelectedExtension}"size="1"label="Ad Series"id="extension">

                    <apex:selectOptionsvalue="{!ExtensionsOptions}"></apex:selectOptions>

            <apex:actionSupportevent="onchange"action="{!populateAdvertizingInfo}"reRender="leadInterest"/> 

                </apex:selectList>

 

1    private Campaign thisCampaign ;

2   public void populateAdvertizingInfo()

3    {

4        List<String> SelectedAdSeries = SelectedExtension.split('-');

5        Decimal ext = Decimal.valueof(SelectedAdSeries[1]);

6        thisCampaign = [Select Campaign_Fully_Qualified__c, Ad_Type__c, Ad_Size__c, Media_Source__c, Project_Code__c,

7                       Type from Campaign where Project__c =: currentLead.Project_site__c AND Extension__c =: ext];

8        system.debug('the campaign '+thisCampaign.id);

9        currentLead.Ad_Type__c = thisCampaign.Ad_Type__c;

10        currentLead.Ad_Size__c = thisCampaign.Ad_Size__c;

11        currentLead.Media_Source__c = thisCampaign.Media_Source__c;

12        currentLead.Project_Code__c = thisCampaign.Project_Code__c;

13       currentLead.Ad_Series__c = thisCampaign.Campaign_Fully_Qualified__c;

14        SelectedCampaignID = thisCampaign.Id;  

15        SelectedCampaignName = thisCampaign.Campaign_Fully_Qualified__c;

16    }

 

It appears that I am getting hung up on the line 6 above.  Any suggestions?

  • September 19, 2013
  • Like
  • 0

Please point me in the right direction.  I've spent the past two days trying to sort through examples that might apply and am just confusing myself more and more....I've run out of time and must get this code deployed to production.  Here's a sample - any help greatly appreciated:

 

This is one of six classes and six triggers that I have to get coverage on...not sure of the best way to proceed.  Thanks in advance!

 

publicwithsharingclass Lead_Creation {

 

    public String searchTerm {get; set;}

    public List<Lead> returnedLeads {get; set;}

    public Boolean isNewLead {get; set;}

    public String SelectedCampaignId {get; set;}

    public String SelectedCampaignName {get; set;}

      

    private Account SelectedProject;

    public Lead currentLead {get; set;}

    

    

    public String SelectedExtension {get; set;}

    public List<SelectOption> getExtensionsOptions()

    {

        SelectedCampaignId = '';

        SelectedCampaignName = '';

        currentLead.Ad_Type__c  = null;

        List<SelectOption> options = new List<SelectOption>();

        options.add(new SelectOption('None','--None--'));

        SelectedExtension = options[0].getLabel();

        for(Campaign c : [SELECT Project_Code__c, Extension__c, Media_Source__r.Name

                          Ad_Size__c, Ad_Type__c FROM Campaign WHERE Project__c =: currentLead.Project_Site__c AND RecordType.Name != 'Parent'])

        {

            string AdType = (c.Ad_Type__c != null ? c.Ad_Type__c : '');

            string AdSize = (c.Ad_Size__c != null ? c.Ad_Size__c : '');

            String ext = c.Project_Code__c+'-'+string.valueof(c.Extension__c)+'-'+c.Media_Source__r.Name+'-'+AdType+'-'+AdSize ;

            options.add(new SelectOption(ext,ext));

        }

        

        if(options.size() == 2)

        {

            SelectedExtension = options[1].getLabel(); 

            populateAdvertizingInfo();

        }

        

        return options;

    }

 

    {

        isNewLead = false;

        

    }

    public Lead_Creation(ApexPages.StandardController controller) {

        currentLead = (Lead)controller.getRecord();

        currentLead.Status = 'Unassigned';

        currentLead.LastName = ' ';

        currentLead.ownerid = UserInfo.getUserId();

    }

    

    public void fetchLeads()

    {

        returnedLeads  = new List<Lead>();

        

        String searchCriteria = '%'+searchTerm+'%';

        

        returnedLeads  = [Select Id, Name, Email, Phone, City, Street, State, Country, Status, Owner.Name, Ownerid

                            FROM Lead 

                            WHERE Email Like : searchCriteria OR Phone Like : searchCriteria  OR Name Like : searchCriteria  Limit 1000];

                            

        if(returnedLeads.isEmpty())

        {

            ApexPages.AddMessage(new ApexPages.Message(ApexPages.Severity.Confirm,'This is a New Lead'));

        }else

        {

            ApexPages.AddMessage(new ApexPages.Message(ApexPages.Severity.Warning,'Similar Leads were found, please verify the list below'));

        }

    }

    

    private Campaign thisCampaign ;

    public void populateAdvertizingInfo()

    {

        List<String> SelectedAdSeries = SelectedExtension.split('-');

        Decimal ext = Decimal.valueof(SelectedAdSeries[1]);

        thisCampaign = [Select Campaign_Fully_Qualified__c, Ad_Type__c, Ad_Size__c, Media_Source__c, Project_Code__c,

                       Type from Campaign where Project__c =: currentLead.Project_site__c AND Extension__c =: ext LIMIT 1];

        system.debug('the campaign '+thisCampaign.id);

        currentLead.Ad_Type__c = thisCampaign.Ad_Type__c;

        currentLead.Ad_Size__c = thisCampaign.Ad_Size__c;

        currentLead.Media_Source__c = thisCampaign.Media_Source__c;

        currentLead.Project_Code__c = thisCampaign.Project_Code__c;

        currentLead.Ad_Series__c = thisCampaign.Campaign_Fully_Qualified__c;

        SelectedCampaignID = thisCampaign.Id;  

        SelectedCampaignName = thisCampaign.Campaign_Fully_Qualified__c;

    }

    

    public void getExtensions()

    {

        getExtensionsOptions();

    }

    

    public PageReference createNewLead()

    {

        isNewLead = true;

 

        return null;

    }

    

    public PageReference saveExt()

    {

        integer err = 0;

        if(currentLead.LastName != null && currentLead.Status != null)

        {

            try{

                currentLead.Extension__c = SelectedExtension;

                insert currentLead;

                

            }catch(Exception e)

            {

                system.debug('the error'+e.getMessage());

                err++;

                return null;

            }

        }else

        {

            if(currentLead.LastName == null)

                currentLead.LastName.addError('This field is required');

            if(currentLead.Status == null)

                currentLead.Status.addError('This field is required');

            return null;

        }

            

        if(err == 0)

        {

            CampaignMember newCM = newCampaignMember(

                                            CampaignId = thisCampaign.id,

                                            LeadId = currentLead.Id,

                                            Status = 'Responded'

                                        );

                

            try{

                insert newCM;

            }catch(Exception e)

            {

                system.debug('the error'+e.getMessage());

            }

            

        }

        

        return new PageReference('/'+currentLead.Id);

    }

 

}

  • September 20, 2013
  • Like
  • 0
Error is in expression '{!populateAdvertizingInfo}' in page lead_creation

 

Class.Lead_Creation.populateAdvertizingInfo: line 88, column 1

---------------------------------

 

Error results on VisualForce page that references the following code on my visualforce page.  What's highlighted in orange is what is failing and the referenced code follows below:

 

<apex:selectListvalue="{!SelectedExtension}"size="1"label="Ad Series"id="extension">

                    <apex:selectOptionsvalue="{!ExtensionsOptions}"></apex:selectOptions>

            <apex:actionSupportevent="onchange"action="{!populateAdvertizingInfo}"reRender="leadInterest"/> 

                </apex:selectList>

 

1    private Campaign thisCampaign ;

2   public void populateAdvertizingInfo()

3    {

4        List<String> SelectedAdSeries = SelectedExtension.split('-');

5        Decimal ext = Decimal.valueof(SelectedAdSeries[1]);

6        thisCampaign = [Select Campaign_Fully_Qualified__c, Ad_Type__c, Ad_Size__c, Media_Source__c, Project_Code__c,

7                       Type from Campaign where Project__c =: currentLead.Project_site__c AND Extension__c =: ext];

8        system.debug('the campaign '+thisCampaign.id);

9        currentLead.Ad_Type__c = thisCampaign.Ad_Type__c;

10        currentLead.Ad_Size__c = thisCampaign.Ad_Size__c;

11        currentLead.Media_Source__c = thisCampaign.Media_Source__c;

12        currentLead.Project_Code__c = thisCampaign.Project_Code__c;

13       currentLead.Ad_Series__c = thisCampaign.Campaign_Fully_Qualified__c;

14        SelectedCampaignID = thisCampaign.Id;  

15        SelectedCampaignName = thisCampaign.Campaign_Fully_Qualified__c;

16    }

 

It appears that I am getting hung up on the line 6 above.  Any suggestions?

  • September 19, 2013
  • Like
  • 0