Execute Now button is not executing the code of scheduled job
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-17-2018 07:29 AM
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 ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-17-2018 07:39 AM
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
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-17-2018 08:09 AM
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-17-2018 08:12 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-17-2018 08:31 AM
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 :-
And the scheduled job I have created is in the same scope "Human Resources: Core ". Below screen hot :-
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