• rohan deoskar
  • NEWBIE
  • 0 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 0
    Questions
  • 2
    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;        
    }
}

When someone takes the time/effort to repspond to your question, you should take the time/effort to either mark the question as "Solved", or post a Follow-Up with addtional information.  

 

That way people with a similar question can find the Solution without having to re-post the same question again and again. And the people who reply to your post know that the issue has been resolved and they can stop working on it.