- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-24-2024 08:51 AM
Hello
I have 2 custom tables One is courses and the other is called enrollment. I build the workflow to schedule job to send out a notification reminder 2 days before class starts. I'm able to send out the notification to the teacher that they owned from the course table. But i don't know how to send out notification to the students who enroll in the courses. Because each courses has different date, number of students and different teacher names. Any suggestion or ideas. Appreciated ! Thanks
Class A Class B Class C
teacher John teacher Smith teacher Mike
10 students 5 students 8 students
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-24-2024 08:34 PM
I think, To send notifications to students enrolled in each course two days before the class starts, you'll need to design a process that iterates through each course record, checks its start date, retrieves enrolled students, and sends notifications to them...means Set up a scheduled job that runs daily to check for courses starting within two days and trigger an event to send notification..below is the sample code
// Query courses starting within two days
var coursesGr = new GlideRecord('courses');
coursesGr.addQuery('start_date', '>=', gs.daysAgo(2)); // Courses starting within two days
coursesGr.addQuery('start_date', '<=', gs.daysAgo(1)); // Courses starting after two days
coursesGr.query();
while (coursesGr.next()) {
var courseName = coursesGr.getValue('name');
var teacher = coursesGr.getValue('teacher');
// Query enrollment for this course
var enrollmentGr = new GlideRecord('enrollment');
enrollmentGr.addQuery('course', coursesGr.getUniqueValue()); // Link to the course
enrollmentGr.query();
while (enrollmentGr.next()) {
var studentName = enrollmentGr.getValue('student');
var email = enrollmentGr.getValue('student_email');
// Queue the event to send notification to student
gs.eventQueue('notification.student.reminder', null, email); // modify as per your event
}
}
Please Mark ✅Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-24-2024 09:09 AM
Hi @SnowDevOps ,
Read the enrollment table data with filter condition where difference of class start date and current date is 2 then trigger the reminder to all enrolled student for that specific course.
Note: dont need to check course or teacher of each record in enrollment table data.
-Thanks,
AshishKM
Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-24-2024 10:31 AM
But how do you send out the notification to the number of students?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-24-2024 07:16 PM
Using event base notification trigger point and pass the course name and recipient name.
iterate the enrolment result set using while loop and trigger the same event for each recipient.
Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-24-2024 08:34 PM
I think, To send notifications to students enrolled in each course two days before the class starts, you'll need to design a process that iterates through each course record, checks its start date, retrieves enrolled students, and sends notifications to them...means Set up a scheduled job that runs daily to check for courses starting within two days and trigger an event to send notification..below is the sample code
// Query courses starting within two days
var coursesGr = new GlideRecord('courses');
coursesGr.addQuery('start_date', '>=', gs.daysAgo(2)); // Courses starting within two days
coursesGr.addQuery('start_date', '<=', gs.daysAgo(1)); // Courses starting after two days
coursesGr.query();
while (coursesGr.next()) {
var courseName = coursesGr.getValue('name');
var teacher = coursesGr.getValue('teacher');
// Query enrollment for this course
var enrollmentGr = new GlideRecord('enrollment');
enrollmentGr.addQuery('course', coursesGr.getUniqueValue()); // Link to the course
enrollmentGr.query();
while (enrollmentGr.next()) {
var studentName = enrollmentGr.getValue('student');
var email = enrollmentGr.getValue('student_email');
// Queue the event to send notification to student
gs.eventQueue('notification.student.reminder', null, email); // modify as per your event
}
}
Please Mark ✅Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.
Thanks