Trigger:
--------
trigger Attendance on Session__c (after insert)
{
Session__c[] s = trigger.new;
Attendance.attendanceupdate(s);
}
Class:
----------
public class Attendance
{
public static void attendanceupdate(Session__c[] session)
{
//for(Session__c s:[SELECT Name,Course__c,Session_Date__c from Session__c ])
for(Session__c s:session)
{
//system.debug('session:'+s);
// for(Enrollment__c e : [SELECT Participant__c from Enrollment__c where Enrollment__c.Course__c = :s.Course__c])
for(Enrollment__c e : [SELECT Participant__c from Enrollment__c where Enrollment__c.Course__c = :s.Course__c AND Enrollment__c.Preparable_Season__c =:s.Season__c AND Enrollment__c.Enrollment_Status__c= 'In Progress'])
{
String inp = 'In progress';
system.debug('enr:'+e);
Attendance__c att = new Attendance__c(Participant__c = e.Participant__c, Present__c=false,Absent__c=false,Excuse_Details__c='',Attendance_Date__c=s.Session_Date__c,Session__c=s.id);
upsert att;
}
}
}
}
No comments:
Post a Comment
Share your Comments .............