My Scheduled Script Execution is failing to run and not showing in the Event Log

nborowiak
Tera Contributor

I have various Scheduled Scripts that are failing to Execute, even when I click the Execute Now button. We paid a vendor to come in and code this for us but I believe there may be a fault or issue in how they coded this. The encoded query is working as intended as I opened the table and applied the same filters that you see below and that provided a list of cases. However, this leads me to believe that the code itself is bad or not working as intended. This job is to run when the encoded query is satisfied > a notification email is then shot off because it's trigger is this event firing off. Please let me know where the code is wrong or incorrect.

var gr = new GlideRecord("sn_hr_core_case_operations");
gr.addEncodedQuery('active=true^hr_service=680a02079f1322003be01050a57fcf85^u_actual_return_dateISEMPTY^u_select_the_type_of_leave_you_would_like_to_request=Continuous');
gr.query();
while (gr.next()) {
    var dueDate = new GlideDate();
    dueDate.setValue(gr.u_approved_start_date);
    var today = new GlideDateTime();
    var diff = new GlideDuration();
    diff = GlideDate.subtract(today, dueDate).getRoundedDayPart();
    gs.info("Diff: " + diff + " " + gr.number);
    if (diff == '-172')
        gs.eventQueue('sn_hr_core.6month.prior.to.expectedstart', gr, 'LOA@email.com');
}
1 ACCEPTED SOLUTION

Sagar Agarwal
Mega Guru

Hi @nborowiak 

 

Can you check the "Run As" field for the scheduled Job? I am assuming the "Run as" field would have a contractor account and not that contractor account is inactivated/disabled you script stopped running.

Update the script to the System Administrator account or any other active admin user in the system.

find_real_file.png

 

 

If my answer helped you in any way, please then mark it as helpful.

Kind regards,

Sagar

View solution in original post

5 REPLIES 5

Donald11
Kilo Explorer
  1. Configure a service activity for an HR service.
  2. Configure the HR ticket page header for an HR service.
  3. Configure the HR case creation form for an HR service.
  4. Configure the HR case form for an HR service.
  5. Add a custom column (field) to an HR table

myindigocard