• bhargavi k 16
  • NEWBIE
  • 0 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 0
    Replies
I didnt get the result of this...can u anyone suggest me...whrere i done a mistake...and i getting error msg like:Method does not exist or incorrect signature: [Contact].size()
Trigger code:
trigger totalcontrigger on Contact (after insert, after update) 
{
    if(trigger.isinsert && trigger.isafter)
    {
        contacthelp.totalcontacts(trigger.new);
    }
}
Class Code:
public class contacthelp {
    public static void totalcontacts(list<contact> conlist){
        Map<id,contact> conmap=new map<id,contact>();
        for(contact c:conlist)
        {
           conmap.put(c.accountid, c) ;
        }
        list<account> acclist=[select id, totalcontacts__c from account where id in:conmap.keyset()];
        for(account a:acclist)
        {
            a.totalcontacts__c=conmap.get(a.id).size();
        }
        update acclist;        
    }
}