Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

scheduled job not running

l4urence
Mega Contributor

Forgive me I am learning

I have submitted a scheduled job, when I click 'execute now' the job does not run. I cannot see an entry in event logs.

If I copy the script from the scheduled job and run it in background scripts - it inserts the rows in event logs and (the rest of the processing) works fine.

var res = new GlideRecord('x_hotel_reservation');

res.addQuery('departure', gs.now());

res.addNotNullQuery('room');

res.query();

while(res.next()){

  gs.eventQueue('x_hotel.room.reservation_end', res.room.getRefRecord());

}

I can only assume something is wrong with the scheduled job I am trying to run.

any help directing me to a solution would be welcomed.

Many thanks for your time.

1 ACCEPTED SOLUTION

Hi,



Since this is a scoped application, it seems your scheduled job is unable to create new records in the sysevent table but when you run it from a background script, the scope is global and you are getting access to add records in the sysevent table. I suggest you try configuring table application access by allowing other application scopes to create records in sysevent table. Please check and let me know



find_real_file.png



Application Access Settings - ServiceNow Wiki



Thanks


Please Hit like, Helpful or Correct depending on the impact of the response


View solution in original post

7 REPLIES 7

Alikutty



Success!


I had to change the suggestion from Rajshekhar since looking at the logs I found:




com.glide.script.fencing.MethodNotAllowedException: Function log is not allowed in scope x_hotel. Use gs.debug() or gs.info() instead




after the table permission changes you suggested, I went back to gs.now() but as he stated this didn't work but proved a point in my head.




I changed his script to use gs.info instead and all worked as it should. I need to reverse out the changes you suggested (to see whether the permissions were connected - but I assume they were needed).




I'm assuming that the combination of both changes (using gs.now() and table permissions - helped me and I thank you both for your help.


Rajshekhar



Success!


looking at the logs I found:



com.glide.script.fencing.MethodNotAllowedException: Function log is not allowed in scope x_hotel. Use gs.debug() or gs.info() instead



after the table permission changes, I went back to gs.now() but as you stated this didn't work but proved a point in my head.



I changed your script to use gs.info instead and all worked as it should. I need to reverse out the changes suggested by Alikutty (to see whether the permissions were connected - but I assume they were needed).



I'm assuming that the combination of both changes helped me and I thank you both for your help.


Hi Laurence,



I am glad that I could help. Thanks for your confirmation.



Regards,


Rajshekhar Paul