• Mobile
  • NEWBIE
  • 0 Points
  • Member since 2009

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 3
    Replies

i am a beginner i managed to create the below trigger to update the campaign member status before lead update. .  

 

can any one help me writing a test class for it.

 

thanks in advance for your help.

 

trigger UpdateMemberStatus on Lead ( before insert ,before update) {

Lead[] leads = Trigger.new;

for (Lead l:leads){

List<CampaignMember> status = new List<CampaignMember>();

// select the status for the most recent campaign for that lead

status = [SELECT status FROM CampaignMember  WHERE leadId = :l.id order by id desc limit 1];

// make sure the lead is assigned to the campaign.

if (!status.isEmpty())

{

status[0].status = l.outcome__c;

update status;

}

}

  • April 14, 2009
  • Like
  • 0

Hi, i'm fairly new to the apex world, the below trigger works fine on the sandbox but in order to deploy it i need a testmethod for it. it would be appreciated if someone could help create a test method for it.

 

thanks in advance. 

 

 trigger CheckDuplicateAccountOnPhone on Account (before insert) {

Account[] accs = Trigger.new;

 

    for (Account a:accs){

     Integer hits;

     String matchCond = a.phone;

System.debug(matchCond);

hits = [SELECT count() FROM Account WHERE phone = :matchCond];

System.debug(hits); 

     if (hits>0)

     {

        trigger.new[0].addError('Account already exists in Database, Please Contact Your Admin To Give you access to it.  ');

     }       

   }

}

 

 

 

 

  • February 11, 2009
  • Like
  • 0

Hi All,  Im fairly new to SF. it would be appreciated if someone could help. 

 

I'm about to import an NON client records into our SF database. we will be running an outbound telemarketing on the data.

 

shall i import them as accounts or leads? what are the advantages and disadvantages?  

 

and if possible what is the best way of running an outbound maketing on those records. 

 

cheers thanks in advance

  • January 24, 2009
  • Like
  • 0

i am a beginner i managed to create the below trigger to update the campaign member status before lead update. .  

 

can any one help me writing a test class for it.

 

thanks in advance for your help.

 

trigger UpdateMemberStatus on Lead ( before insert ,before update) {

Lead[] leads = Trigger.new;

for (Lead l:leads){

List<CampaignMember> status = new List<CampaignMember>();

// select the status for the most recent campaign for that lead

status = [SELECT status FROM CampaignMember  WHERE leadId = :l.id order by id desc limit 1];

// make sure the lead is assigned to the campaign.

if (!status.isEmpty())

{

status[0].status = l.outcome__c;

update status;

}

}

  • April 14, 2009
  • Like
  • 0

Hi, i'm fairly new to the apex world, the below trigger works fine on the sandbox but in order to deploy it i need a testmethod for it. it would be appreciated if someone could help create a test method for it.

 

thanks in advance. 

 

 trigger CheckDuplicateAccountOnPhone on Account (before insert) {

Account[] accs = Trigger.new;

 

    for (Account a:accs){

     Integer hits;

     String matchCond = a.phone;

System.debug(matchCond);

hits = [SELECT count() FROM Account WHERE phone = :matchCond];

System.debug(hits); 

     if (hits>0)

     {

        trigger.new[0].addError('Account already exists in Database, Please Contact Your Admin To Give you access to it.  ');

     }       

   }

}

 

 

 

 

  • February 11, 2009
  • Like
  • 0

Hi All,  Im fairly new to SF. it would be appreciated if someone could help. 

 

I'm about to import an NON client records into our SF database. we will be running an outbound telemarketing on the data.

 

shall i import them as accounts or leads? what are the advantages and disadvantages?  

 

and if possible what is the best way of running an outbound maketing on those records. 

 

cheers thanks in advance

  • January 24, 2009
  • Like
  • 0