Reply
Trusted Contributor
Amber Neill
Posts: 169

Roll-up Summary Fields that aren't

I need to be able to have two fields.

1.) on the Contact object - # of Campaigns

2.) on the Cases object - # of Activities

These fields will let me keep a Contact from getting to much marketing stuff and will help our Support QA department look at number of interactions.

I can't use roll-up summary fields.  How should I tackle this problem?

Any advice you can offer is much appreciated.

Thanks,

Amber

 

Regular Contributor
alvatse
Posts: 76

Re: Roll-up Summary Fields that aren't

I recently did something similar on the Contact object to roll up a field from a custom object that's built with master-detail relationship to the Contact object. Not sure if this is the only way, but I believe master-detail relationship allows you to do rollup.
Regular Contributor
ktm
Posts: 25

Re: Roll-up Summary Fields that aren't

The master-detail part is the issue. Has anyone come up with a workaround for look-ups? Isn't there a way to count the number of records in a related list that isn't part of a master-detail relationship.

 

Super Contributor
jkucera
Posts: 730

Re: Roll-up Summary Fields that aren't

One workaround - use a Campaign Member trigger to increment a custom field on Contact any time a Contact is added to a campaign.  You'd need a 2nd trigger (delete) to decrement the count any time this contact is removed. 

 

Post on how to do this on campaigns (increment, not decrement):

http://blogs.salesforce.com/marketing/2009/05/track-campaign-rsvps-with-campaign-member-triggers-summer-09-part-1.html

 

Increment Trigger syntax might look something like:

 

trigger UpdateCmpRegistered on CampaignMember (before update) { Contact c = [select Id, name from Contact where Id = :Trigger.new[0].ContactId limit 1]; for(CampaignMember cm : Trigger.new){ c.Registered__c += 1; } try{ update(c); } catch(DMLException e){ System.debug('Contact update failed:' + e); }//try }

 

 

 

John Kucera
Product Manager - Salesforce Chatter
Free Chatter Unfollow Rules App