Count Of Contacts

trigger CountOfContact on Contact (after insert, after update, after delete) {
    
    list<account> acc=[select id, number__c, (select id, accountid from contacts) from Account];
    list<account> act=new list<account>();
    for(account aa:acc){
        aa.number__c = aa.contacts.size();
        act.add(aa);
    }
    update act;
}




























Comments

Popular posts from this blog

Page Layouts

SOQL Scenario-1