Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- trigger certificationToFailedNew on Exam__c (after update) {
- //List out all the exams associated with the parent of the triggered object. exam record -> ParentID -> other child records which share the same parent
- List<Exam__c> exams = new List<Exam__c>();
- exams = [
- SELECT Id,Exam_id__c, Exam_state__c, Certification__r.Id, Certification__r.Exam_state__c
- FROM Exam__c
- 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()
- AND id != id IN :trigger.newMap.keySet()];
- trigger certificationToFailedNew on Exam__c (after update) {
- set<id> certificationId = new set<id>();
- String x;
- String y;
- for(Exam__c e : Trigger.new){
- certificationId.add(e.Certification__c);
- x = e.Exam_id__c;
- y = e.Exam_state__c;
- }
- List<Exam__c> exams = new List<Exam__c>();
- exams = [
- SELECT Id, Exam_id__c, Exam_state__c, Certification__r.Id, Certification__r.Exam_state__c
- FROM Exam__c
- WHERE Exam_state__c in ('Failed') AND Certification__r.Exam_state__c in ('Active')
- AND Id NOT IN :trigger.newMap.keySet() AND Certification__r.Id IN :certificationId
- AND Exam_id__c = :x AND Exam_state__c = :y];
- }
- 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()
- AND id != id IN :trigger.newMap.keySet()];
- Certification__c NOT IN :setOfParents
- Certification__c IN :setOfParents AND id NOT IN :trigger.newMap.keySet()
- trigger certificationToFailedNew on Exam__c (after update) {
- set<id> certificationId = new set<id>();
- for(Exam__c e : Trigger.new){
- certificationId.add(e.Certification__c);
- }
- List<Exam__c> exams = [SELECT Id,Exam_id__c, Exam_state__c,Certification__r.Id,
- Certification__r.Exam_state__c FROM Exam__c
- WHERE Exam_state__c = 'Failed' AND Certification__r.Exam_state__c = 'Active'
- AND Certification__r.id IN :certificationId AND id NOT IN :trigger.newMap.keySet()];
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement