3

I need to create a campaign member based off of a custom field value on the lead object. I'm a newbie to the world of apex but hopefully this will better help me understand the process.

When

Custom_Field__c = My New Campaign

CREATE ----------- >>> New campaign member of campaign (My New Campaign)

Any help would be greatly appreciated.

1 Answer 1

2

This is job for trigger! :) As you are newbie I will give you some tips to show you way, but details you should find by yourself ;)

So, create trigger for lead - best idea should be after insert/update: http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_triggers.htm

In trigger create new instance of campaignMember (fill all required fields based on your lead) http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_objects_campaignmember.htm

then insert your instance of campaignMember and enjoy your new campaignMember :D

To be honest I think this question is not specific enough and could be easly close. So try follow steps I described and in case of any errors or problems please ask again. The forum is place where you could find help with your problems - not someone who make your job.

2
  • Thank you so very much for pointing me in the right direction!
    – Aaron
    Commented Mar 17, 2014 at 15:27
  • This, as Arthur Described, if you want to expand this logic more, I suggest having a CampaignCode for your Campaigns and a custom field on your Lead/Contact which you can query Campaigns and create Campaign Members dynamically as described
    – Double A
    Commented Mar 17, 2014 at 15:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .