• bz
  • NEWBIE
  • 0 Points
  • Member since 2013

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

I have a trigger I would like to roll out to production, but I am getting errors with test classes from installed packages.

 

Specifically related to Chatter Answers.  I am unable to delete or inactivate chatter_answers_question_escalation_to_case_trigger.

 

Any suggestions would be helpful.

 

 

  • July 24, 2013
  • Like
  • 0

Getting Error when trying to deploy simple trigger to production with 95% code coverage.

 

Problem: Cannot deploy InstalledPackage in Package Manifest with any other types!

 

Any ideas what this means and what I need to change to help fix?

  • July 22, 2013
  • Like
  • 0

Getting Error when trying to deploy simple trigger to production with 95% code coverage.

 

Problem: Cannot deploy InstalledPackage in Package Manifest with any other types!

 

Any ideas what this means and what I need to change to help fix?

  • July 22, 2013
  • Like
  • 0

Hi All.

 

I'm hoping someone can help with this simple fix.

 

I have the following code below that looks at a lead field called custom field hubspot_campaign_c (this has a campaign ID in) and if it is not null it adds the lead to the specific campaign listed in hubspot_campaign_c.

 

trigger LeadToCampaign on Lead (after update, after insert) {
 
for (Lead l: trigger.new) {

if (l.HubSpot_Campaign__c != null ) {
           CampaignMember cm = new CampaignMember();
                cm = new CampaignMember();
                cm.LeadId = l.Id;
                cm.CampaignId = l.HubSpot_Campaign__c; //You will have to know the ID or query for it or something
                cm.Status = 'Responded'; //Or whatever default status you want on the member
                
            insert cm;

}
}
}

 

This works perfectly fine but it generates an error if the lead record is updated because the lead will already exist in the campaign.

 

So what I need help on is to add a line which queries the campaignmembers and checks to see if the lead already exists for the campaignID listed in the custom field hubspot_campaign_c.

 

So what I was trying to do was create a list of campaign members where the leadID matches in the campaign member list but this is where I got stuck.  This will generate a list of campaigns the lead is in and I then need to filter it by campaignid = hubspot_campaign_c and then if campaignmember list is null add the campaign member.  

 

trigger LeadToCampaign on Lead (after update, after insert) {

List<Id> leads=new List<Id>();

for (Lead l: trigger.new) {

List<CampaignMember> cms=[Select LeadID, CampaignID FROM CampaignMember WHERE LeadID IN: leads];
        
if (l.HubSpot_Campaign__c != null) {
           CampaignMember cm = new CampaignMember();
                cm = new CampaignMember();
                cm.LeadId = l.Id;
                cm.CampaignId = l.HubSpot_Campaign__c; //You will have to know the ID or query for it or something
                cm.Status = 'Responded'; //Or whatever default status you want on the member
                
            insert cm;

}
}
}

 

Any help would be much appreciated.


Kev