Execute Now button is not executing the code of scheduled job

kamlesh kjmar
Mega Sage
Mega Sage

Hi,

I have written a scheduled job to execute daily at 6 am. After writing the code when I saved it and clicked on execute now button, page refreshes but it do not do anything i.e. script do not executes.

But when I copy the same code and executes it from Background script it works perfectly fine. Any idea why is that ?

 

12 REPLIES 12

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Kamlesh,

Did you check by adding log statements at the first line of code and last line of code?

There could be a possibility that code got broken in between.

Can you check in active transactions from left navigation whether the schedule job executed or not or is being executed currently on specific node.

There could be a possibility that no node was available to execute this job hence it didn't run.

Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

I tried executing just one line also gs.log("Inside script"). But this is not working.

 

Is it because I have created scheduled job in different scope "Human Resources: Core". If yes then how should I fix this ?

 

Thanks,

Kamlesh

Yes, that's the issue with scope.

First, execute your code via background script to check if your code is running fine.

If it executes successfully via background script, create new new scheduled job in correct scope to resolve issue.

 

Regards,

Sachin

Hi Sachin,

 

It is executing from background script and this is what confusing me. The table that I am querying is a scoped application table but accessible from all scope. Below the screen shot :-

find_real_file.png

 

And the scheduled job I have created is in the same scope "Human Resources: Core ". Below screen hot :-

find_real_file.png

 

What is wrong that I have done that this schedule job is not executing at all even clicking on "Execute Now" button. I mean how would I identify that I have used wrong application and what should be the right one ?

 

Thanks,

Kamlesh