"How to write rollup summary for lookup and how to update roll up summary using lookup." Code Answer's
You're definitely familiar with the best coding language Whatever that developers use to develop their projects and they get all their queries like "How to write rollup summary for lookup and how to update roll up summary using lookup." answered properly. Developers are finding an appropriate answer about How to write rollup summary for lookup and how to update roll up summary using lookup. related to the Whatever coding language. By visiting this online portal developers get answers concerning Whatever codes question like How to write rollup summary for lookup and how to update roll up summary using lookup.. Enter your desired code related query in the search bar and get every piece of information about Whatever code related question on How to write rollup summary for lookup and how to update roll up summary using lookup..
How to write rollup summary for lookup and how to update roll up summary using lookup.
trigger CountContactsnew on Contact (after insert, after delete, after undelete) {
List<id> accIdList = new List<id>();
if(Trigger.isInsert || Trigger.isUndelete){
For(Contact con1 : Trigger.new){
accIdList.add(con1.accountid);
}
}
if(Trigger.isDelete){
For(Contact con1 : Trigger.old){
accIdList.add(con1.accountid);
}
}
List<Account> accUpdateList = new List<Account>();
For(Account acc : [SELECT Contact_Recs__c,(SELECT id FROM Contacts) FROM Account WHERE id =: accIdList]){
acc.Contact_Recs__c = acc.Contacts.size();
accUpdateList.add(acc);
}
try{
update accUpdateList;
}Catch(Exception e){
System.debug('Exception :'+e.getMessage());
}
}
Source: salesforce.stackexchange.com
All those coders who are working on the Whatever based application and are stuck on How to write rollup summary for lookup and how to update roll up summary using lookup. can get a collection of related answers to their query. Programmers need to enter their query on How to write rollup summary for lookup and how to update roll up summary using lookup. related to Whatever code and they'll get their ambiguities clear immediately. On our webpage, there are tutorials about How to write rollup summary for lookup and how to update roll up summary using lookup. for the programmers working on Whatever code while coding their module. Coders are also allowed to rectify already present answers of How to write rollup summary for lookup and how to update roll up summary using lookup. while working on the Whatever language code. Developers can add up suggestions if they deem fit any other answer relating to "How to write rollup summary for lookup and how to update roll up summary using lookup.". Visit this developer's friendly online web community, CodeProZone, and get your queries like How to write rollup summary for lookup and how to update roll up summary using lookup. resolved professionally and stay updated to the latest Whatever updates.