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;
}
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
Post a Comment