Guest User

Untitled

a guest
Feb 25th, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 KB | None | 0 0
  1. trigger updateEvent on ObjectB__c(after update) {
  2.  
  3. Set<Id> objectAId = new Set<Id>();
  4. Set<Id> objectA2Id = new Set<Id>();
  5. Set<Id> ssfIds2 = new Set<Id>();
  6. Set<Id> objectDId = new Set<Id>();
  7. Decimal rollUp1 = 0;
  8. Decimal rollUp2 = 0;
  9. Decimal totalNumerator;
  10. Decimal totalDenominator;
  11.  
  12. for(ObjectB__c b : Trigger.New) {
  13. objectAId.add(b.ObjectA__c);
  14. }
  15.  
  16. List<ObjectC__c> objCList = [SELECT Id, Name, ObjectD__c, ObjectA__c, ObjectA__r.Name,
  17. ObjectA__r.StandardRollUp1__c, ObjectA__r.StandardRollUp2__c FROM
  18. ObjectC__c WHERE ObjectA__c IN: objectAId];
  19.  
  20. for(ObjectC__c c : objCList) {
  21. objectA2Id.add(c.ObjectA__c);
  22. }
  23.  
  24. for(ObjectC__c c : objCList) {
  25. objectDId.add(c.ObjectD__c);
  26. }
  27.  
  28. List<Event> eList = [SELECT Id, Answer__c FROM Event WHERE ObjectD__c IN: objectDId];
  29.  
  30. for(Event e : eList) {
  31.  
  32. for(ObjectC__c c : objCList) {
  33.  
  34. rollUp1 += c.ObjectA__r.StandardRollUp1__c;
  35. rollUp2 += c.ObjectA__r.StandardRollUp2__c;
  36.  
  37. totalNumerator = rollUp1;
  38. totalDenominator = rollUp2;
  39.  
  40. e.Answer__c = totalNumerator/totalDenominator;
  41.  
  42. }
  43.  
  44.  
  45. }
  46.  
  47. update eList;
  48.  
  49. }
Add Comment
Please, Sign In to add comment