Trigger same event while scheduled job runs in 2 different condition

1_DipikaD
Kilo Sage

Hi All,

I have a schedule job which triggers an event . Now the recipients receives a reminder only when the capacity review due date was 14 days away. Want to send  an additional reminder 7 days before the due date. What changes should i make on the below script in schedule job so that I can achieve it ?

 

 

5 REPLIES 5

Ankur Bawiskar
Tera Patron

@1_DipikaD 

try this

var gr_user = new GlideRecord('u_capacity_reviews');
gr_user.addEncodedQuery('u_status=pending^active=true');
gr_user.query();
while (gr_user.next()) {
    var reviewdate = new GlideDateTime(gr_user.u_capacity_review_due_date.toString());
    
    // Calculate 14 days before the due date
    var reminder14Days = new GlideDateTime(reviewdate);
    reminder14Days.addDaysLocalTime(-14);
    
    // Calculate 7 days before the due date
    var reminder7Days = new GlideDateTime(reviewdate);
    reminder7Days.addDaysLocalTime(-7);
    
    var currentDate = new GlideDate().getDisplayValue();
    
    // Check if today is 14 days or 7 days before the due date
    if (currentDate == reminder14Days.getDisplayValue() || currentDate == reminder7Days.getDisplayValue()) {
        gs.eventQueue('notify.capacity.reviewers', gr_user, gr_user.u_application_instance.u_support_owner, gr_user.u_application_instance.owned_by);
    }
}

If my response helped please mark it correct and close the thread so that it benefits future readers.

Unable trigger mail after this schedule script . I have checked email logs , not getting the emails that i observed.

@1_DipikaD 

what debugging did you perform?

did you add logs and see?

If my response helped please mark it correct and close the thread so that it benefits future readers.

I have tried the below script and actually I don't want to change anything on the highlighted part. Just want to add the the script for 7 days . Please correct me if my script is wrong. I have tried this and then observed the schedule log that it's last run is 22nd where the schedule job runs daily . For today there are no logs.  I am adding the pics of schedule job and schedule log for your reference.