Salesforce for Twitter is one of the best AppExchange packages I've seen. It fulfills the promise salesforce.com made to bring the Service Cloud to all orgs of all sizes. And it works well.
Though a supplemental/unofficial guide to customizing SFDC for Twitter will be released soon on this site, I wanted to share a trigger I just wrote to add new Leads to a campaign:
Firstly, thank you to Scott Hemmeter at Arrowpointe, who wrote the original code that I customized.
Secondly, you could easily duplicate this trigger and set it to run on the Contact object as well.
Please don't set the trigger to "after update," as in testing, it ran into problems when converting a Lead and merging with a Contact already on the "Twitter" campaign.
trigger AddToTwitterCampaign on Lead (after insert) { // List containing each Lead being processed list<Lead> theLeads = new list<Lead>(); //We only execute if we have a campaign named "Twitter" if([SELECT Count() FROM Campaign WHERE name = 'Twitter'] == 1){ Campaign TC = [SELECT id, name FROM Campaign WHERE name = 'Twitter' LIMIT 1]; for(Lead l:trigger.new) { if (l.leadsource.indexOf('Twitter',0 ) >= 0 || l.leadsource.indexOf('Tweet',0 ) >= 0 ){ theLeads.add(l); // add lead to the main lead list } } // List containing Campaign Member records to be inserted list <CampaignMember> theCampaignMembers = new list<CampaignMember>(); for (Lead ld:theLeads) { CampaignMember cml = new CampaignMember(); cml.leadid = ld.id; cml.campaignid = TC.id; theCampaignMembers.add(cml); } //Insert the list of Campaign Members if(!theCampaignMembers.isEmpty()){ insert theCampaignMembers; } } }
The trigger requires that you have a Campaign called "Twitter," but feel free to change that to anything else you'd like.
Don't worry if you have other triggers that add Leads to Campaigns - this can work alongside them, so you can add Leads to as many Campaigns as you'd like.
Share Your Thoughts