+ Start a Discussion
footprint_ninafootprint_nina 

Adding Contact's Opportunities to a Campaign

Hi,

I am trying to retroactively piece together our campaigns from 2009 that were not recorded properly. I added all the contacts that we sent a summer appeal to the campaign i created for the summer appeal. Now i was wondering if it is possible to run an advanced search on all of those contacts to find out all of their associated opportunities so i  determine which ones were a response to the appeal. Any ideas?

 

thanks!

jkucerajkucera

I think you're asking how to see these contacts oppty's - is that right? 

 

A report won't do as you can't go from oppty-->acct-->contact as accoutn is the parent of both.  

 

Do you already have contact roles on those oppty's for those contacts?  If so, campaign influence report should do the trick.

 

If not, you could either batch add a lot of contact roles,or add a flag to Account set to true for any account containing one of these contact. Both would require code to set up.

footprint_ninafootprint_nina

Unfortunately not all of them have contact roles. I would definitely like to batch add contact roles for all our opportunities (not just the ones for this campaign) because they have been inconsistently used in the past. How do i do that?

 

thanks!

jkucerajkucera

 

Are these contacts from converted leads?  If so, an even simpler way to get this is the leads w/ converted lead history report as it will have both the contact ID's and the resulting opportunities.

 

If not, here's the much more complex batch apex way:

1) Create a batch apex class which has a method to add contact roles for all contacts in a query

2) Create a VF apex controller which calls the batch apex class, and supplies the query that grabs the appropriate contacts

3) Create a VF page with a tag in the page tag action ='methodFromcontroller'

4) Create a button which will run the VF page once clicked.

 

 I haven't used nested queries, but something like this should get you the contacts you want:

([Select contacts where ID IN (select ContactID from CampaignMEmber where CampaignID=...)]

 

Your batch apex would:

 - Get a set of accounts based on these contacts

 - Get all opportunties for these accounts (unless you have a way to ignore opp's not from those contacts)

 - Add contact roles for each oppty for each contact in the query above for the oppty's account

footprint_ninafootprint_nina
None of them are converted leads, but i already have them in a spreadsheet with Contact IDs. Unfortunately, i think the batch APEX way is a little out of my realm of experience as i havent ever used them before. but thanks for your help!
jkucerajkucera

If you have less than say 50,000 contacts, you could attempt to do some Excel magic if you are comfortable with the data loader or excel connector:

 

 - Export campaign members to get contactID's

 - Export all contacts, do a vlookup to match to the campaign member table

 - do a pivot table on the matches to get a list of unique accountID's

 - Export all accounts, do a vlookup to get the relevent ones & create a new tab w/ only these account ID's

 - Export all Opportunities, do a vlookup on the relevent account ID's

 - Create a new tab w/ only the relevent opportunities

 - Create a new ContactRole tab w/ the contact ID's for each account for each relevent opportunity

 

 Depends how important it is to you

footprint_ninafootprint_nina
thanks! i'll try that!
jkucerajkucera

Sounds good - btw the trickiest part will be the final step as you need to creat several contactID rows for each opportunity ID as there likely will be a bunch of oppty's with several contacts in that campaign. 

 

That might be best done manually if you have a low amount of oppty's (100 or less).