Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- trigger updateEvent on ObjectB__c(after update) {
- Set<Id> objectAId = new Set<Id>();
- Set<Id> objectA2Id = new Set<Id>();
- Set<Id> ssfIds2 = new Set<Id>();
- Set<Id> objectDId = new Set<Id>();
- Decimal rollUp1 = 0;
- Decimal rollUp2 = 0;
- Decimal totalNumerator;
- Decimal totalDenominator;
- for(ObjectB__c b : Trigger.New) {
- objectAId.add(b.ObjectA__c);
- }
- List<ObjectC__c> objCList = [SELECT Id, Name, ObjectD__c, ObjectA__c, ObjectA__r.Name,
- ObjectA__r.StandardRollUp1__c, ObjectA__r.StandardRollUp2__c FROM
- ObjectC__c WHERE ObjectA__c IN: objectAId];
- for(ObjectC__c c : objCList) {
- objectA2Id.add(c.ObjectA__c);
- }
- for(ObjectC__c c : objCList) {
- objectDId.add(c.ObjectD__c);
- }
- List<Event> eList = [SELECT Id, Answer__c FROM Event WHERE ObjectD__c IN: objectDId];
- for(Event e : eList) {
- for(ObjectC__c c : objCList) {
- rollUp1 += c.ObjectA__r.StandardRollUp1__c;
- rollUp2 += c.ObjectA__r.StandardRollUp2__c;
- totalNumerator = rollUp1;
- totalDenominator = rollUp2;
- e.Answer__c = totalNumerator/totalDenominator;
- }
- }
- update eList;
- }
Add Comment
Please, Sign In to add comment