function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
SF_StevenSF_Steven 

Apex Trigger: Assign Lead to Campaign on Upsert Based on RecordTypeID

The subject line says it all - I just figured out the data model and have the groundwork done for my implementation.  This is one of two issues an Apex trigger can solve.  

 

Thanks in advance!

Best Answer chosen by Admin (Salesforce Developers) 
SF_StevenSF_Steven

Solved - thanks to Scott Hemmeter!

 

http://sfdc.arrowpointe.com/2008/09/13/bulkifying-a-trigger-an-example/

 

I was able to modify the code here to meet my needs.   This also helped to make Apex 'click" on in my brian.   I was able to wirte triggers for coverting leads and a status update important to my processes on insert.

 

 

All Answers

ngabraningabrani

Steven,

What specific problem you are running into when developing this trigger?

SF_StevenSF_Steven

Honestly, I wish I was further along than just stating the problem!  :smileysad:

 

I have never programmed in Java before so I'm spending today reading some intoductions and basic coding examples online.   I'm also only on my second day of using Salesforce.com - but since I've used other CRM platforms before, it's been fairly intuitive.  

 

I just downloaded the Helios release of Eclipse and I'm about to install the Force.com IDE.   That should help me get the basics down.

 

In case it helps or if there's another non-Apex way to do what I need (don't think there is though), I'll add some specifics:

 

1.  Leads are the start of my sales process - leads are imported into Salesforce.com.

2.  Each lead type I load has a RecordTypeID appended to the file.   This is because each lead type I work required a different page layout.

3.  The page layouts happen to correspond to campaigns.   It would be nice to have a trigger that fires off after upsert that looks at the RecordTypeID and then adds them to a Campaign as members.

 

 

So let's say:

 

RecordTypeID          Campaign Member

   AA1                  -->           1

   AA2                 -->            2

   BDD               -->            3

 

I might figure this out on my own in a couple weeks - I'm not on a burning platform on this or anything.   I'm not really sure if this code or what I'm asking for is bigger than a bread box.

 

Thanks!

 

SF_StevenSF_Steven

Solved - thanks to Scott Hemmeter!

 

http://sfdc.arrowpointe.com/2008/09/13/bulkifying-a-trigger-an-example/

 

I was able to modify the code here to meet my needs.   This also helped to make Apex 'click" on in my brian.   I was able to wirte triggers for coverting leads and a status update important to my processes on insert.

 

 

This was selected as the best answer