- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-09-2024 11:41 AM
Hello,
I have a requirement to send out a notification based on.
- Number of options remaining is greater than zero
- Should be sent 90 days prior to the current period of performance end date
How would I do this in the email notification configuration? Actual steps would be very helpful. Thank you.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2024 08:28 PM
You can run a schedule job on daily basis , you can modify below script
var currentDate = new GlideDateTime();
// Calculate the target date (90 days prior to the current period of performance end date)
var targetDate = new GlideDateTime(); // Assuming 'currentRecord' is the record you're working with
targetDate.setDisplayValue(currentRecord.u_period_of_performance_end_date); // Replace with the actual field name
// Calculate the difference in days
var daysDifference = GlideDate.subtract(targetDate, currentDate);
// Check conditions
if (currentRecord.u_options_remaining > 0 && daysDifference > 90) {
// Send notification logic here
gs.eventQueue('notification.event.type', currentRecord, '90 days notification');
}
Please mark my answer correct/helpful if it helps you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-09-2024 12:16 PM
Hello,
You can use a scheduled job to Glide the table and filter the records that satisfy the condition and trigger an event to send the email for those records.
Thank you,
Mitesh.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2024 06:57 PM
Would me running it periodically with 90 days be correct based on my requirements? I've never created a scheduled job before and I'm wrecking myself trying to figure this out.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2024 11:39 PM
The scheduled job should run daily as there is a possibility that there will be a new record everyday that has performance end date as 90 days from the today.
Please mark my answer as helpful if it solves your issue.
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2024 07:25 PM - edited 02-12-2024 07:26 PM
Hi,
create scheduled job with below code:
var chkDate = new GlideDate();
chkDate.addDays(90);
var rec = new GlideRecord('u_infra_certificates');//replace your table name
rec.addQuery('u_cert_expiry_date', chkDate); //replace with your date field
rec.query();
while (rec.next()) {
gs.eventQueue("knowledge.expiring", rec, event,parm1,event.parm2);
}
Please hit like and mark my response as correct if that helps
Thanks & Regards,
Sumanth Meda.