Send notification based on date of event

Andre241
Tera Contributor

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.

1 ACCEPTED SOLUTION

Maddysunil
Kilo Sage

@Andre241 

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!

View solution in original post

5 REPLIES 5

Maddysunil
Kilo Sage

@Andre241 

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!