is it possible to create a custom object which will take information from all contacts under an account and aggregate information into that account record? Here's what i'm trying to do specifically...

I want to take the lead scores of all contacts in an account and combine their scores into one large score for that account.

Is that possible?

  • Sounds like a regular roll-up summary field. Have you tried that, assuming your score is numeric? – Mike Chale Aug 14 '13 at 15:35
  • the score is numeric and I have not tried the roll-up summary. thank you for the suggestion! – Josh Mellott Aug 14 '13 at 15:36
  • You can't rollup from Contact to Account. A common pain, and ridiculous that its not available – Chris Duncombe Aug 14 '13 at 15:39

This could be done either by a trigger or a batch job, depending on if you need to the account information to be updated in real time or if its something that could be daily, weekly, etc.

I would likely create a batch job for this, and then shcedule it to run whenever you want. Heres a sample I made from some batch jobs I have

global class myBatchJob implements Database.Batchable<sObject>{

    global final string query;

    global myBatchJob(){
        query = 'Select Id, Name, AccountLeadScore__c, (Select Id, Name, ContactLeadScore__c From Contacts) From Account';      

    global Database.QueryLocator start(Database.BatchableContext BC){

        return Database.getQueryLocator(query);

    global void execute(Database.BatchableContext BC,List<sObject> scope)
        List<Account> updateAccounts = new List<Account>();

        for(Sobject s : scope){
            Account a = (Account) s;
            a.AccountLeadScore = 0;
            for(Contact c : a.Contacts){
                a.AccountLeadScore__c += c.ContactLeadScore__c

            update updateAccounts;
        }catch (Exception e) {  
            //your trapping

    global void finish(Database.BatchableContext BC)
        System.debug(LoggingLevel.WARN,'Batch Job complete');


I believe you will be able to score contacts(aggregated) and accounts with 'ZakScorer'. You can find this app on appexchange and try it for yourself.

To install ZakScorer, click here...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.