Posts

Showing posts from October, 2018

Roll up Amount from Child Object To Parent Object in Case of Lookup Relationship

Case : Roll up the values from Child to Parent Object in Case of Lookup Relationship. On Child Object (ChildObjectApiName__c) there is custom field Amount__c On Parent Object(ParentObjectApiName__c) there is a custom Field TotalChildAmount__c On Child Object relation ship of Parent Object is ParentObjectRealtionShipApiName__c Trigger triggerName on ChildObjectApiName__c(aftet insert, after delete, after update, after undelete) { set<id> setofParentObjectID = new set<id>(); // Storing the parent object Ids map<Id, ParentObjectApiName__c> mapofParentObjectIdToParnetObject  = new Map<Id, ParentObjectApiName__c>(); // Map is used for Storing the Parent Record Id to Parent Object if(Trigger.isInsert || Trigger.isUpdate || Trigger.isUndelete) { for(ChildObjectApiName__c objChildObject1: trigger.new) { if(objChildObject1.ParentObjectRealtionShipApiName__c != null) { setofParentObjectID.add(objChildObject1.ParentObjectRealtionShip