Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.23 KB | None | 0 0
  1. trigger certificationToFailedNew on Exam__c (after update) {
  2. //List out all the exams associated with the parent of the triggered object. exam record -> ParentID -> other child records which share the same parent
  3. List<Exam__c> exams = new List<Exam__c>();
  4. exams = [
  5. SELECT Id,Exam_id__c, Exam_state__c, Certification__r.Id, Certification__r.Exam_state__c
  6. FROM Exam__c
  7. WHERE Exam_state__c in ('Failed') AND Certification__r.Exam_state__c in ('Active') AND Certification__r.id == Certification__c.id IN :trigger.newMap.keySet()
  8. AND id != id IN :trigger.newMap.keySet()];
  9.  
  10. trigger certificationToFailedNew on Exam__c (after update) {
  11.  
  12. set<id> certificationId = new set<id>();
  13. String x;
  14. String y;
  15.  
  16. for(Exam__c e : Trigger.new){
  17. certificationId.add(e.Certification__c);
  18. x = e.Exam_id__c;
  19. y = e.Exam_state__c;
  20. }
  21.  
  22. List<Exam__c> exams = new List<Exam__c>();
  23. exams = [
  24. SELECT Id, Exam_id__c, Exam_state__c, Certification__r.Id, Certification__r.Exam_state__c
  25. FROM Exam__c
  26. WHERE Exam_state__c in ('Failed') AND Certification__r.Exam_state__c in ('Active')
  27. AND Id NOT IN :trigger.newMap.keySet() AND Certification__r.Id IN :certificationId
  28. AND Exam_id__c = :x AND Exam_state__c = :y];
  29. }
  30.  
  31. WHERE Exam_state__c in ('Failed') AND Certification__r.Exam_state__c in ('Active')
  32. AND Certification__r.id == Certification__c.id IN :trigger.newMap.keySet()
  33. AND id != id IN :trigger.newMap.keySet()];
  34.  
  35. Certification__c NOT IN :setOfParents
  36.  
  37. Certification__c IN :setOfParents AND id NOT IN :trigger.newMap.keySet()
  38.  
  39. trigger certificationToFailedNew on Exam__c (after update) {
  40. set<id> certificationId = new set<id>();
  41. for(Exam__c e : Trigger.new){
  42. certificationId.add(e.Certification__c);
  43. }
  44. List<Exam__c> exams = [SELECT Id,Exam_id__c, Exam_state__c,Certification__r.Id,
  45. Certification__r.Exam_state__c FROM Exam__c
  46. WHERE Exam_state__c = 'Failed' AND Certification__r.Exam_state__c = 'Active'
  47. AND Certification__r.id IN :certificationId AND id NOT IN :trigger.newMap.keySet()];
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement